Sha256: 39d52a844e101dacdbf8448d1dd9a5e4f233353c8c8496351c8d442decad8851

Contents?: true

Size: 809 Bytes

Versions: 12

Compression:

Stored size: 809 Bytes

Contents

'use strict';
// https://tc39.github.io/proposal-setmap-offrom/
var aFunction = require('../internals/a-function');
var bind = require('../internals/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

12 entries across 12 versions & 4 rubygems

Version Path
disco_app-0.18.0 test/dummy/node_modules/core-js/internals/collection-from.js
disco_app-0.18.2 test/dummy/node_modules/core-js/internals/collection-from.js
condenser-0.0.8 lib/condenser/processors/node_modules/core-js-pure/internals/collection-from.js
jester-data-8.0.0 node_modules/core-js/internals/collection-from.js
ezii-os-5.2.1 node_modules/core-js/internals/collection-from.js
ezii-os-2.0.1 node_modules/core-js/internals/collection-from.js
ezii-os-1.1.0 node_modules/core-js/internals/collection-from.js
ezii-os-1.0.0 node_modules/core-js/internals/collection-from.js
condenser-0.0.7 lib/condenser/processors/node_modules/core-js-pure/internals/collection-from.js
ezii-os-0.0.0.1.0 node_modules/core-js/internals/collection-from.js
ezii-os-0.0.0.0.1 node_modules/core-js/internals/collection-from.js
condenser-0.0.5 lib/condenser/processors/node_modules/core-js-pure/internals/collection-from.js