es.array.find.js 771 B

12345678910111213141516171819202122
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var $find = require('../internals/array-iteration').find;
  4. var addToUnscopables = require('../internals/add-to-unscopables');
  5. var FIND = 'find';
  6. var SKIPS_HOLES = true;
  7. // Shouldn't skip holes
  8. // eslint-disable-next-line es/no-array-prototype-find -- testing
  9. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  10. // `Array.prototype.find` method
  11. // https://tc39.es/ecma262/#sec-array.prototype.find
  12. $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  13. find: function find(callbackfn /* , that = undefined */) {
  14. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  15. }
  16. });
  17. // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
  18. addToUnscopables(FIND);