You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
parttimejob/node_modules/core-js/internals/collection-from.js

25 lines
906 B

4 weeks ago
'use strict';
// https://tc39.github.io/proposal-setmap-offrom/
var bind = require('../internals/function-bind-context');
var anObject = require('../internals/an-object');
var toObject = require('../internals/to-object');
var iterate = require('../internals/iterate');
module.exports = function (C, adder, ENTRY) {
return function from(source /* , mapFn, thisArg */) {
var O = toObject(source);
var length = arguments.length;
var mapFn = length > 1 ? arguments[1] : undefined;
var mapping = mapFn !== undefined;
var boundFunction = mapping ? bind(mapFn, length > 2 ? arguments[2] : undefined) : undefined;
var result = new C();
var n = 0;
iterate(O, function (nextItem) {
var entry = mapping ? boundFunction(nextItem, n++) : nextItem;
if (ENTRY) adder(result, anObject(entry)[0], entry[1]);
else adder(result, entry);
});
return result;
};
};