Socket
Socket
Sign inDemoInstall

zen-observable

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zen-observable - npm Package Compare versions

Comparing version 0.8.6 to 0.8.7

scripts/babel-plugins.js

58

lib/Observable.js

@@ -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 () {

6

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc