zen-observable
Advanced tools
Comparing version 0.8.13 to 0.8.14
@@ -55,3 +55,7 @@ 'use strict'; | ||
var count = sources.length; | ||
var values = new Map(); | ||
var seen = new Set(); | ||
var seenAll = false; | ||
var values = sources.map(function () { | ||
return undefined; | ||
}); | ||
@@ -61,4 +65,13 @@ var subscriptions = sources.map(function (source, index) { | ||
next: function (v) { | ||
values.set(index, v); | ||
if (values.size === sources.length) observer.next(Array.from(values.values())); | ||
values[index] = v; | ||
if (!seenAll) { | ||
seen.add(index); | ||
if (seen.size !== sources.length) return; | ||
seen = null; | ||
seenAll = true; | ||
} | ||
observer.next(Array.from(values)); | ||
}, | ||
@@ -65,0 +78,0 @@ error: function (e) { |
{ | ||
"name": "zen-observable", | ||
"version": "0.8.13", | ||
"version": "0.8.14", | ||
"repository": "zenparsing/zen-observable", | ||
@@ -11,4 +11,4 @@ "description": "An Implementation of ES Observables", | ||
"babel-preset-es2015": "^6.24.1", | ||
"eslint": "^4.16.0", | ||
"mocha": "^5.0.0" | ||
"eslint": "^5.16.0", | ||
"mocha": "^6.1.2" | ||
}, | ||
@@ -15,0 +15,0 @@ "dependencies": {}, |
@@ -35,9 +35,20 @@ import { Observable } from './Observable.js'; | ||
let count = sources.length; | ||
let values = new Map(); | ||
let seen = new Set(); | ||
let seenAll = false; | ||
let values = sources.map(() => undefined); | ||
let subscriptions = sources.map((source, index) => Observable.from(source).subscribe({ | ||
next(v) { | ||
values.set(index, v); | ||
if (values.size === sources.length) | ||
observer.next(Array.from(values.values())); | ||
values[index] = v; | ||
if (!seenAll) { | ||
seen.add(index); | ||
if (seen.size !== sources.length) | ||
return; | ||
seen = null; | ||
seenAll = true; | ||
} | ||
observer.next(Array.from(values)); | ||
}, | ||
@@ -44,0 +55,0 @@ error(e) { |
@@ -24,2 +24,21 @@ import assert from 'assert'; | ||
}); | ||
it('should emit values in the correct order', async () => { | ||
let output = []; | ||
await combineLatest( | ||
parse('-a-b-c-d'), | ||
parse('A-B-C-D') | ||
).forEach( | ||
value => output.push(value.join('')) | ||
); | ||
assert.deepEqual(output, [ | ||
'aA', | ||
'aB', | ||
'bB', | ||
'bC', | ||
'cC', | ||
'cD', | ||
'dD', | ||
]); | ||
}); | ||
}); |
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
72126
2188