zen-observable
Advanced tools
Comparing version 0.8.2 to 0.8.3
@@ -12,6 +12,2 @@ 'use strict'; | ||
var _Observable2 = _interopRequireDefault(_Observable); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// Emits all values from all inputs in parallel | ||
@@ -23,4 +19,4 @@ function merge() { | ||
return new _Observable2.default(function (observer) { | ||
if (sources.length === 0) return _Observable2.default.from([]); | ||
return new _Observable.Observable(function (observer) { | ||
if (sources.length === 0) return _Observable.Observable.from([]); | ||
@@ -30,3 +26,3 @@ var count = sources.length; | ||
var subscriptions = sources.map(function (source) { | ||
return _Observable2.default.from(source).subscribe({ | ||
return _Observable.Observable.from(source).subscribe({ | ||
next: function (v) { | ||
@@ -58,4 +54,4 @@ observer.next(v); | ||
return new _Observable2.default(function (observer) { | ||
if (sources.length === 0) return _Observable2.default.from([]); | ||
return new _Observable.Observable(function (observer) { | ||
if (sources.length === 0) return _Observable.Observable.from([]); | ||
@@ -66,3 +62,3 @@ var count = sources.length; | ||
var subscriptions = sources.map(function (source, index) { | ||
return _Observable2.default.from(source).subscribe({ | ||
return _Observable.Observable.from(source).subscribe({ | ||
next: function (v) { | ||
@@ -95,4 +91,4 @@ values.set(index, v); | ||
return new _Observable2.default(function (observer) { | ||
if (sources.length === 0) return _Observable2.default.from([]); | ||
return new _Observable.Observable(function (observer) { | ||
if (sources.length === 0) return _Observable.Observable.from([]); | ||
@@ -103,4 +99,10 @@ var queues = sources.map(function () { | ||
function done() { | ||
return queues.some(function (q, i) { | ||
return q.length === 0 && subscriptions[i].closed; | ||
}); | ||
} | ||
var subscriptions = sources.map(function (source, index) { | ||
return _Observable2.default.from(source).subscribe({ | ||
return _Observable.Observable.from(source).subscribe({ | ||
next: function (v) { | ||
@@ -110,5 +112,8 @@ queues[index].push(v); | ||
return q.length > 0; | ||
})) observer.next(queues.map(function (q) { | ||
return q.shift(); | ||
})); | ||
})) { | ||
observer.next(queues.map(function (q) { | ||
return q.shift(); | ||
})); | ||
if (done()) observer.complete(); | ||
} | ||
}, | ||
@@ -119,3 +124,3 @@ error: function (e) { | ||
complete: function () { | ||
observer.complete(); | ||
if (done()) observer.complete(); | ||
} | ||
@@ -122,0 +127,0 @@ }); |
{ | ||
"name": "zen-observable", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"repository": "zenparsing/zen-observable", | ||
@@ -16,3 +16,3 @@ "description": "An Implementation of ES Observables", | ||
"scripts": { | ||
"test": "mocha --require babel-core/register", | ||
"test": "mocha --recursive --require babel-core/register", | ||
"lint": "eslint src/*", | ||
@@ -19,0 +19,0 @@ "build": "git clean -dfX ./lib && babel src --out-dir lib", |
@@ -1,2 +0,2 @@ | ||
import Observable from './Observable.js'; | ||
import { Observable } from './Observable.js'; | ||
@@ -12,5 +12,12 @@ // Emits all values from all inputs in parallel | ||
let subscriptions = sources.map(source => Observable.from(source).subscribe({ | ||
next(v) { observer.next(v) }, | ||
error(e) { observer.error(e) }, | ||
complete() { if (--count === 0) observer.complete(); }, | ||
next(v) { | ||
observer.next(v); | ||
}, | ||
error(e) { | ||
observer.error(e); | ||
}, | ||
complete() { | ||
if (--count === 0) | ||
observer.complete(); | ||
}, | ||
})); | ||
@@ -37,4 +44,9 @@ | ||
}, | ||
error(e) { observer.error(e) }, | ||
complete() { if (--count === 0) observer.complete(); }, | ||
error(e) { | ||
observer.error(e); | ||
}, | ||
complete() { | ||
if (--count === 0) | ||
observer.complete(); | ||
}, | ||
})); | ||
@@ -54,10 +66,22 @@ | ||
function done() { | ||
return queues.some((q, i) => q.length === 0 && subscriptions[i].closed); | ||
} | ||
let subscriptions = sources.map((source, index) => Observable.from(source).subscribe({ | ||
next(v) { | ||
queues[index].push(v); | ||
if (queues.every(q => q.length > 0)) | ||
if (queues.every(q => q.length > 0)) { | ||
observer.next(queues.map(q => q.shift())); | ||
if (done()) | ||
observer.complete(); | ||
} | ||
}, | ||
error(e) { observer.error(e) }, | ||
complete() { observer.complete() }, | ||
error(e) { | ||
observer.error(e); | ||
}, | ||
complete() { | ||
if (done()) | ||
observer.complete(); | ||
}, | ||
})); | ||
@@ -64,0 +88,0 @@ |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ import { testMethodProperty } from './properties.js'; |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -6,4 +5,2 @@ import { testMethodProperty } from './properties.js'; | ||
describe('from', () => { | ||
const observableSymbol = Symbol.observable || '@@observable'; | ||
const iterable = { | ||
@@ -48,3 +45,3 @@ *[Symbol.iterator]() { | ||
'constructor': Observable, | ||
[observableSymbol]() { return this }, | ||
[Symbol.observable]() { return this }, | ||
}; | ||
@@ -56,3 +53,3 @@ assert.ok(Observable.from(obj) !== obj); | ||
assert.throws(() => Observable.from({ | ||
[observableSymbol]: 1 | ||
[Symbol.observable]: 1 | ||
})); | ||
@@ -71,3 +68,3 @@ }); | ||
let observable = Observable.from({ | ||
[observableSymbol]() { return inner }, | ||
[Symbol.observable]() { return inner }, | ||
}); | ||
@@ -74,0 +71,0 @@ observable.subscribe(); |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ import { testMethodProperty } from './properties.js'; |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ import { testMethodProperty } from './properties.js'; |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ import { testMethodProperty } from './properties.js'; |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ import { testMethodProperty } from './properties.js'; |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ import { testMethodProperty } from './properties.js'; |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ |
import { Observable } from '../src/Observable.js'; | ||
beforeEach(() => { | ||
global.Observable = Observable; | ||
global.hostError = null; | ||
@@ -5,0 +6,0 @@ let $extensions = Object.getOwnPropertySymbols(Observable)[1]; |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ import { testMethodProperty } from './properties.js'; |
@@ -1,2 +0,1 @@ | ||
import { Observable } from '../src/Observable.js'; | ||
import assert from 'assert'; | ||
@@ -3,0 +2,0 @@ import { testMethodProperty } from './properties.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
66153
33
1972