zen-observable
Advanced tools
Comparing version 0.8.6 to 0.8.7
@@ -429,2 +429,60 @@ 'use strict'; | ||
}, { | ||
key: 'flatMap', | ||
value: function flatMap(fn) { | ||
var _this6 = this; | ||
if (typeof fn !== 'function') throw new TypeError(fn + ' is not a function'); | ||
var C = getSpecies(this); | ||
return new C(function (observer) { | ||
var subscriptions = []; | ||
var outer = _this6.subscribe({ | ||
next: function (value) { | ||
if (fn) { | ||
try { | ||
value = fn(value); | ||
} catch (e) { | ||
return observer.error(e); | ||
} | ||
} | ||
var inner = C.from(value).subscribe({ | ||
next: function (value) { | ||
observer.next(value); | ||
}, | ||
error: function (e) { | ||
observer.error(e); | ||
}, | ||
complete: function () { | ||
var i = subscriptions.indexOf(inner); | ||
if (i >= 0) subscriptions.splice(i, 1); | ||
completeIfDone(); | ||
} | ||
}); | ||
subscriptions.push(inner); | ||
}, | ||
error: function (e) { | ||
observer.error(e); | ||
}, | ||
complete: function () { | ||
completeIfDone(); | ||
} | ||
}); | ||
function completeIfDone() { | ||
if (outer.closed && subscriptions.length === 0) observer.complete(); | ||
} | ||
return function () { | ||
subscriptions.forEach(function (s) { | ||
return s.unsubscribe(); | ||
}); | ||
outer.unsubscribe(); | ||
}; | ||
}); | ||
} | ||
}, { | ||
key: getSymbol('observable'), | ||
@@ -431,0 +489,0 @@ value: function () { |
{ | ||
"name": "zen-observable", | ||
"version": "0.8.6", | ||
"version": "0.8.7", | ||
"repository": "zenparsing/zen-observable", | ||
@@ -16,7 +16,7 @@ "description": "An Implementation of ES Observables", | ||
"scripts": { | ||
"test": "mocha --recursive --require babel-core/register", | ||
"test": "mocha --recursive --require ./scripts/mocha-require", | ||
"lint": "eslint src/*", | ||
"build": "git clean -dfX ./lib && babel src --out-dir lib", | ||
"build": "git clean -dfX ./lib && node ./scripts/build", | ||
"prepublishOnly": "eslint src/* && npm test && npm run build" | ||
} | ||
} |
@@ -344,2 +344,46 @@ // === Symbol Support === | ||
flatMap(fn) { | ||
if (typeof fn !== 'function') | ||
throw new TypeError(fn + ' is not a function'); | ||
let C = getSpecies(this); | ||
return new C(observer => { | ||
let subscriptions = []; | ||
let outer = this.subscribe({ | ||
next(value) { | ||
if (fn) { | ||
try { value = fn(value) } | ||
catch (e) { return observer.error(e) } | ||
} | ||
let inner = C.from(value).subscribe({ | ||
next(value) { observer.next(value) }, | ||
error(e) { observer.error(e) }, | ||
complete() { | ||
let i = subscriptions.indexOf(inner); | ||
if (i >= 0) subscriptions.splice(i, 1); | ||
completeIfDone(); | ||
}, | ||
}); | ||
subscriptions.push(inner); | ||
}, | ||
error(e) { observer.error(e) }, | ||
complete() { completeIfDone() }, | ||
}); | ||
function completeIfDone() { | ||
if (outer.closed && subscriptions.length === 0) | ||
observer.complete(); | ||
} | ||
return () => { | ||
subscriptions.forEach(s => s.unsubscribe()); | ||
outer.unsubscribe(); | ||
}; | ||
}); | ||
} | ||
[getSymbol('observable')]() { return this } | ||
@@ -346,0 +390,0 @@ |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
70279
36
2116
2
1