All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.internals.array-slice-simple.js Maven / Gradle / Ivy

There is a newer version: 3.39.0
Show newest version
'use strict';
var toAbsoluteIndex = require('../internals/to-absolute-index');
var lengthOfArrayLike = require('../internals/length-of-array-like');
var createProperty = require('../internals/create-property');

var $Array = Array;
var max = Math.max;

module.exports = function (O, start, end) {
  var length = lengthOfArrayLike(O);
  var k = toAbsoluteIndex(start, length);
  var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  var result = $Array(max(fin - k, 0));
  var n = 0;
  for (; k < fin; k++, n++) createProperty(result, n, O[k]);
  result.length = n;
  return result;
};




© 2015 - 2024 Weber Informatics LLC | Privacy Policy