main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
906 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | // https://tc39.github.io/proposal-setmap-offrom/
|
---|
3 | var bind = require('../internals/function-bind-context');
|
---|
4 | var anObject = require('../internals/an-object');
|
---|
5 | var toObject = require('../internals/to-object');
|
---|
6 | var iterate = require('../internals/iterate');
|
---|
7 |
|
---|
8 | module.exports = function (C, adder, ENTRY) {
|
---|
9 | return function from(source /* , mapFn, thisArg */) {
|
---|
10 | var O = toObject(source);
|
---|
11 | var length = arguments.length;
|
---|
12 | var mapFn = length > 1 ? arguments[1] : undefined;
|
---|
13 | var mapping = mapFn !== undefined;
|
---|
14 | var boundFunction = mapping ? bind(mapFn, length > 2 ? arguments[2] : undefined) : undefined;
|
---|
15 | var result = new C();
|
---|
16 | var n = 0;
|
---|
17 | iterate(O, function (nextItem) {
|
---|
18 | var entry = mapping ? boundFunction(nextItem, n++) : nextItem;
|
---|
19 | if (ENTRY) adder(result, anObject(entry)[0], entry[1]);
|
---|
20 | else adder(result, entry);
|
---|
21 | });
|
---|
22 | return result;
|
---|
23 | };
|
---|
24 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.