shim.js 533 B

1234567891011121314151617
  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) {
  12. result[i] = val;
  13. });
  14. return result;
  15. };