shim.js 540 B

1234567891011121314151617181920212223242526
  1. "use strict";
  2. var callable = require("../../../object/valid-callable")
  3. , ensureValue = require("../../../object/valid-value")
  4. , some = Array.prototype.some
  5. , apply = Function.prototype.apply;
  6. module.exports = function (predicate /*, thisArg*/) {
  7. var k, self;
  8. self = Object(ensureValue(this));
  9. callable(predicate);
  10. return some.call(
  11. self,
  12. function (value, index) {
  13. if (apply.call(predicate, this, arguments)) {
  14. k = index;
  15. return true;
  16. }
  17. return false;
  18. },
  19. arguments[1]
  20. )
  21. ? k
  22. : -1;
  23. };