UNPKG

moltres-utils

Version:
63 lines (52 loc) 2.38 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _ramda = require('ramda'); function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } var mapSeries = (0, _ramda.curry)(function () { var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(fn, data) { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: return _context2.abrupt('return', (0, _ramda.reduce)(function () { var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(promise, value) { var accum, result; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return promise; case 2: accum = _context.sent; _context.next = 5; return fn(value); case 5: result = _context.sent; return _context.abrupt('return', (0, _ramda.append)(result, accum)); case 7: case 'end': return _context.stop(); } } }, _callee, undefined); })); return function (_x3, _x4) { return _ref2.apply(this, arguments); }; }(), Promise.resolve([]), data)); case 1: case 'end': return _context2.stop(); } } }, _callee2, undefined); })); return function (_x, _x2) { return _ref.apply(this, arguments); }; }()); exports.default = mapSeries; //# sourceMappingURL=mapSeries.js.map