find-key.js 415 B

1234567891011121314151617181920212223
  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(t(o, function () {
  11. ++i;
  12. return true;
  13. }), '1', "Finds");
  14. a(i, 1, "Stops iteration after condition is met");
  15. a(t(o, function () {
  16. return false;
  17. }), undefined, "Fails");
  18. };