find.js 421 B

123456789101112131415161718192021222324
  1. "use strict";
  2. var o = { 1: 1, 2: 2, 3: 3 };
  3. module.exports = function (t, a) {
  4. var o2 = {}, i = 0;
  5. t(o, function (value, name) {
  6. o2[name] = value;
  7. return false;
  8. });
  9. a(JSON.stringify(o2), JSON.stringify(o), "Iterates");
  10. a(
  11. t(o, function () {
  12. ++i;
  13. return true;
  14. }),
  15. 1,
  16. "Finds"
  17. );
  18. a(i, 1, "Stops iteration after condition is met");
  19. a(t(o, function () { return false; }), undefined, "Fails");
  20. };