some.js 263 B

12345678910
  1. export default function some(values, test) {
  2. if (typeof test !== "function") throw new TypeError("test is not a function");
  3. let index = -1;
  4. for (const value of values) {
  5. if (test(value, ++index, values)) {
  6. return true;
  7. }
  8. }
  9. return false;
  10. }