@graffy/stream
Advanced tools
Comparing version 0.14.1 to 0.14.2-alpha1
43
index.js
@@ -12,2 +12,6 @@ "use strict"; | ||
/* | ||
This file should not use async/await as it's intended to be usable without | ||
the regenerator polyfill. | ||
*/ | ||
var normalCompletion = _promise["default"].resolve({ | ||
@@ -19,3 +23,3 @@ value: void 0, | ||
function makeStream(init, options) { | ||
var _ref; | ||
var _ref2; | ||
@@ -63,3 +67,3 @@ if (options === void 0) { | ||
var close = init(push, end); | ||
return _ref = { | ||
return _ref2 = { | ||
debugId: debugId, | ||
@@ -78,6 +82,31 @@ next: function next() { | ||
}, | ||
"return": function _return(val) { | ||
complete = normalCompletion; | ||
map: function map(fn) { | ||
var _this = this; | ||
return makeStream(function (push, end) { | ||
var next = function next() { | ||
_this.next().then(function (_ref) { | ||
var value = _ref.value, | ||
done = _ref.done; | ||
if (done) return end(); | ||
push(fn(value)); | ||
next(); | ||
})["catch"](function (error) { | ||
return end(error); | ||
}); | ||
}; | ||
next(); | ||
return function (error, value) { | ||
error ? _this["throw"](error) : _this["return"](value); | ||
}; | ||
}); | ||
}, | ||
"return": function _return(value) { | ||
complete = _promise["default"].resolve({ | ||
value: value, | ||
done: true | ||
}); | ||
payloads.length = 0; | ||
close(null, val); | ||
close(null, value); | ||
return complete; | ||
@@ -91,7 +120,7 @@ }, | ||
} | ||
}, _ref[_asyncIterator["default"]] = function () { | ||
}, _ref2[_asyncIterator["default"]] = function () { | ||
return this; | ||
}, _ref; | ||
}, _ref2; | ||
} | ||
module.exports = exports.default; |
@@ -5,3 +5,3 @@ { | ||
"author": "aravind (https://github.com/aravindet)", | ||
"version": "0.14.1", | ||
"version": "0.14.2-alpha1", | ||
"main": "index.js", | ||
@@ -8,0 +8,0 @@ "source": "src/index.js", |
@@ -0,1 +1,6 @@ | ||
/* | ||
This file should not use async/await as it's intended to be usable without | ||
the regenerator polyfill. | ||
*/ | ||
const normalCompletion = Promise.resolve({ value: void 0, done: true }); | ||
@@ -44,6 +49,24 @@ | ||
return(val) { | ||
complete = normalCompletion; | ||
map(fn) { | ||
return makeStream((push, end) => { | ||
const next = () => { | ||
this.next() | ||
.then(({ value, done }) => { | ||
if (done) return end(); | ||
push(fn(value)); | ||
next(); | ||
}) | ||
.catch(error => end(error)); | ||
}; | ||
next(); | ||
return (error, value) => { | ||
error ? this.throw(error) : this.return(value); | ||
}; | ||
}); | ||
}, | ||
return(value) { | ||
complete = Promise.resolve({ value, done: true }); | ||
payloads.length = 0; | ||
close(null, val); | ||
close(null, value); | ||
return complete; | ||
@@ -50,0 +73,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
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
8864
176