Repository URL to install this package:
|
Version:
6.0.4 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var is_1 = require("../../is");
var curry_1 = require("../../fp/curry");
var keys_1 = require("../../util/keys");
var preAllocate_1 = require("../../array/preAllocate");
var _reduce_1 = require("./_reduce");
function _map(fn, functorList) {
var idx = 0;
var len = functorList.length;
var result = preAllocate_1.default(len);
while (idx < len) {
result[idx] = fn(functorList[idx]);
idx += 1;
}
return result;
}
/**
* @desc `while (index < list.length) push fn(list[index++])`
* @name _map
* @alias baseMaps
* @since 5.0.0-beta.1
* @memberOf loop
*
* {@link https://github.com/ramda/ramda/blob/master/src/internal/_map.js ramda-_map}
* @see {@link ramda-_map}
*
* @param fn function to apply
* @param functorList function/list
*/
function map(fn, functor) {
if (is_1.isFunction(functor)) {
return curry_1.default(functor.length, function () {
return fn.call(this, functor.apply(this, arguments));
});
}
else if (is_1.isObjTag(functor)) {
return _reduce_1.default(function (acc, key) {
acc[key] = fn(functor[key]);
return acc;
}, {}, keys_1.default(functor));
}
else {
return _map(fn, functor);
}
}
exports.default = map;
//# sourceMappingURL=_map.js.map