moltres-utils
Version:
Utils for Moltres apps
66 lines (57 loc) • 1.67 kB
JavaScript
require("core-js/modules/es6.object.define-property");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.baseAllWith = exports.default = void 0;
var _all = require("./all");
var _resolveWith = require("./resolveWith");
var _curry = _interopRequireDefault(require("./curry"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var baseAllWith = function baseAllWith(fn, value) {
return (0, _resolveWith.baseResolveWith)(fn, (0, _all.baseAll)(value));
};
/**
* Resolves all async values in an array or object and executes the given with the result
*
* Auto curried for placeholder support.
*
* @function
* @since v0.0.13
* @category common
* @param {Function} fn The function to execute at the end of the resolution
* @param {*} value The array or object whose values should be resolved. If value is not an object or array, the value is simply resolved to itself
* @returns {*} The array or object with its values resolved
* @example
*
* const nums = [
* 1,
* Promise.resolve(2),
* (async () => 3)()
* ]
* await allWith(
* (resolvedNums) => 'foo', // [ 1, 2, 3 ]
* nums
* ) // => 'foo'
*
* const keyed = {
* a: 1,
* b: Promise.resolve(2),
* c: (async () => 3)()
* }
*
* await allWith(
* (resolvedNums) => 'foo', // { a: 1, b: 2, c: 3 }
* keyed
* ) // => 'foo'
*
* allWith(
* (resolvedNums) => 'foo', // [ 1, 2, 3 ]
* [ 1, 2, 3 ]
* ) // => 'foo'
*/
exports.baseAllWith = baseAllWith;
var allWith = (0, _curry.default)(baseAllWith);
var _default = allWith;
exports.default = _default;
//# sourceMappingURL=allWith.js.map
;