Sha256: cf390953d64bb86bca2ae66d771716a9c51fa04a2c13b5e0abe2494aecaa306e

Contents?: true

Size: 818 Bytes

Versions: 13

Compression:

Stored size: 818 Bytes

Contents

'use strict';
// https://tc39.github.io/proposal-setmap-offrom/
var aFunction = require('../internals/a-function');
var bind = require('../internals/function-bind-context');
var iterate = require('../internals/iterate');

module.exports = function from(source /* , mapFn, thisArg */) {
  var length = arguments.length;
  var mapFn = length > 1 ? arguments[1] : undefined;
  var mapping, A, n, boundFunction;
  aFunction(this);
  mapping = mapFn !== undefined;
  if (mapping) aFunction(mapFn);
  if (source == undefined) return new this();
  A = [];
  if (mapping) {
    n = 0;
    boundFunction = bind(mapFn, length > 2 ? arguments[2] : undefined, 2);
    iterate(source, function (nextItem) {
      A.push(boundFunction(nextItem, n++));
    });
  } else {
    iterate(source, A.push, A);
  }
  return new this(A);
};

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/core-js/internals/collection-from.js
tang-0.2.1 spec/tang_app/node_modules/core-js/internals/collection-from.js
tang-0.2.0 spec/tang_app/node_modules/core-js/internals/collection-from.js
tang-0.1.0 spec/tang_app/node_modules/core-js/internals/collection-from.js
tang-0.0.9 spec/tang_app/node_modules/core-js/internals/collection-from.js
enju_library-0.3.8 spec/dummy/node_modules/core-js/internals/collection-from.js
condenser-0.3 lib/condenser/processors/node_modules/core-js-pure/internals/collection-from.js
condenser-0.2 lib/condenser/processors/node_modules/core-js-pure/internals/collection-from.js
condenser-0.1 lib/condenser/processors/node_modules/core-js-pure/internals/collection-from.js
condenser-0.0.12 lib/condenser/processors/node_modules/core-js-pure/internals/collection-from.js
condenser-0.0.11 lib/condenser/processors/node_modules/core-js-pure/internals/collection-from.js
condenser-0.0.10 lib/condenser/processors/node_modules/core-js-pure/internals/collection-from.js
condenser-0.0.9 lib/condenser/processors/node_modules/core-js-pure/internals/collection-from.js