shim.js 468 B

1234567891011121314
  1. 'use strict';
  2. var isPlainArray = require('../../is-plain-array')
  3. , isArray = Array.isArray, splice = Array.prototype.splice
  4. , forEach = Array.prototype.forEach;
  5. module.exports = function (start, deleteCount/*, …items*/) {
  6. var arr = splice.apply(this, arguments), result;
  7. if (!this || !isArray(this) || isPlainArray(this)) return arr;
  8. result = new this.constructor(arr.length);
  9. forEach.call(arr, function (val, i) { result[i] = val; });
  10. return result;
  11. };