Comparing version 1.2.1 to 1.2.2
@@ -18,3 +18,3 @@ const { | ||
this.sinks.delete(sink) | ||
if (this.sinks.size===0) { | ||
if (this.sinks.size === 0) { | ||
this.defer() | ||
@@ -137,2 +137,30 @@ } | ||
} | ||
class Zip extends Sink { | ||
init(index, array, context) { | ||
this.index = index | ||
this.context = context | ||
this.array = array | ||
this.buffer = [] | ||
array[index] = this.buffer | ||
} | ||
next(data) { | ||
this.buffer.push(data) | ||
if (this.array.every(x => x.length)) { | ||
this.sink.next(this.array.map(x => x.shift())) | ||
} | ||
} | ||
complete(err) { | ||
if (err || (--this.context.nLife) === 0) super.complete(err) | ||
} | ||
} | ||
exports.zip = (...sources) => sink => { | ||
const nTotal = sources.length; | ||
const context = { | ||
nTotal, | ||
nLife: nTotal | ||
} | ||
const array = new Array(nTotal) | ||
sources.forEach((source, i) => source(new Zip(sink, i, array, context))) | ||
} | ||
exports.startWith = (...xs) => inputSource => (sink, pos = 0, l = xs.length) => { | ||
@@ -139,0 +167,0 @@ while (pos < l) { |
@@ -60,2 +60,3 @@ declare namespace Rx { | ||
combineLatest(...sources: Array<Observable>): Observable | ||
zip(...sources: Array<Observable>): Observable | ||
never(): Observable | ||
@@ -108,2 +109,3 @@ empty(): Observable | ||
export function combineLatest(...sources: Array<Observable>): Observable | ||
export function zip(...sources: Array<Observable>): Observable | ||
export function never(): Observable | ||
@@ -110,0 +112,0 @@ export function empty(): Observable |
{ | ||
"name": "fastrx", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "fast rxjs implemention", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46496
1364