some.js 655 B

123456789101112131415161718192021222324252627
  1. var makeIterator = require('../function/makeIterator_');
  2. /**
  3. * Array some
  4. */
  5. function some(arr, callback, thisObj) {
  6. callback = makeIterator(callback, thisObj);
  7. var result = false;
  8. if (arr == null) {
  9. return result;
  10. }
  11. var i = -1, len = arr.length;
  12. while (++i < len) {
  13. // we iterate over sparse items since there is no way to make it
  14. // work properly on IE 7-8. see #64
  15. if ( callback(arr[i], i, arr) ) {
  16. result = true;
  17. break;
  18. }
  19. }
  20. return result;
  21. }
  22. module.exports = some;