diff --git a/src/rx-custom/add/filterUndefined.ts b/src/rx-custom/add/filterUndefined.ts new file mode 100644 index 0000000..40c7257 --- /dev/null +++ b/src/rx-custom/add/filterUndefined.ts @@ -0,0 +1,10 @@ +import { Observable } from "rxjs" +import { filterUndefined } from "../operator/filterUndefined" + +declare module "rxjs/Observable" { + interface Observable { + filterUndefined: typeof filterUndefined; + } +} + +Observable.prototype.filterUndefined = filterUndefined diff --git a/src/rx-custom/operator/filterUndefined.ts b/src/rx-custom/operator/filterUndefined.ts new file mode 100644 index 0000000..774fe74 --- /dev/null +++ b/src/rx-custom/operator/filterUndefined.ts @@ -0,0 +1,5 @@ +import { Observable } from "rxjs" + +export function filterUndefined(this: Observable): Observable { + return this.filter(x => typeof x !== "undefined") +} diff --git a/src/setup.ts b/src/setup.ts index 7320b26..679aa4f 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -8,4 +8,6 @@ import "rxjs/add/operator/delay" import "rxjs/add/operator/catch" import "rxjs/add/observable/of" +import "rx-custom/add/filterUndefined" + // const isDev = (process && process.env && process.env.NODE_ENV) !== "production"