Last active
May 10, 2018 13:08
-
-
Save bluepnume/a8bca6ab290f513c788573ada2c2f9a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var serialAsyncMap = function () { | |
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(collection, fn) { | |
var result, _iterator, _isArray, _i, _ref2, item; | |
return regeneratorRuntime.wrap(function _callee$(_context) { | |
while (1) { | |
switch (_context.prev = _context.next) { | |
case 0: | |
result = []; | |
_iterator = collection, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator](); | |
case 2: | |
if (!_isArray) { | |
_context.next = 8; | |
break; | |
} | |
if (!(_i >= _iterator.length)) { | |
_context.next = 5; | |
break; | |
} | |
return _context.abrupt("break", 20); | |
case 5: | |
_ref2 = _iterator[_i++]; | |
_context.next = 12; | |
break; | |
case 8: | |
_i = _iterator.next(); | |
if (!_i.done) { | |
_context.next = 11; | |
break; | |
} | |
return _context.abrupt("break", 20); | |
case 11: | |
_ref2 = _i.value; | |
case 12: | |
item = _ref2; | |
_context.t0 = result; | |
_context.next = 16; | |
return fn(item); | |
case 16: | |
_context.t1 = _context.sent; | |
_context.t0.push.call(_context.t0, _context.t1); | |
case 18: | |
_context.next = 2; | |
break; | |
case 20: | |
return _context.abrupt("return", result); | |
case 21: | |
case "end": | |
return _context.stop(); | |
} | |
} | |
}, _callee, this); | |
})); | |
return function serialAsyncMap(_x, _x2) { | |
return _ref.apply(this, arguments); | |
}; | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment