shim.js 529 B

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