2
0

shim.js 568 B

12345678910111213141516171819
  1. 'use strict';
  2. var isFunction = require('../../function/is-function')
  3. , slice = Array.prototype.slice, defineProperty = Object.defineProperty
  4. , desc = { configurable: true, enumerable: true, writable: true, value: null };
  5. module.exports = function (/*…items*/) {
  6. var result, i, l;
  7. if (!this || (this === Array) || !isFunction(this)) return slice.call(arguments);
  8. result = new this(l = arguments.length);
  9. for (i = 0; i < l; ++i) {
  10. desc.value = arguments[i];
  11. defineProperty(result, i, desc);
  12. }
  13. desc.value = null;
  14. result.length = l;
  15. return result;
  16. };