Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const pipeData = function(fn) {
- return function(data) {
- return Promise.resolve(fn(data)).then(function(res) {
- if (res === void 0) {
- return data;
- }
- const keys = Object.keys(res).filter(function(prop) {
- return res.hasOwnProperty(prop);
- });
- return Promise.all(keys.map(function(prop) {
- return res[prop];
- })).then(function(vals) {
- keys.forEach(function(prop, i) {
- data[prop] = vals[i];
- });
- return data;
- });
- });
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement