SHARE
TWEET

Untitled

a guest Oct 16th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const pipeData = function(fn) {
  2.   return function(data) {
  3.     return Promise.resolve(fn(data)).then(function(res) {
  4.       if (res === void 0) {
  5.         return data;
  6.       }
  7.       const keys = Object.keys(res).filter(function(prop) {
  8.         return res.hasOwnProperty(prop);
  9.       });
  10.       return Promise.all(keys.map(function(prop) {
  11.         return res[prop];
  12.       })).then(function(vals) {
  13.         keys.forEach(function(prop, i) {
  14.           data[prop] = vals[i];
  15.         });
  16.         return data;
  17.       });
  18.     });
  19.   };
  20. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top