_iterate.js 663 B

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. module.exports = function (t, a) {
  3. var o = { raz: 1, dwa: 2, trzy: 3 }, o2 = {}, o3 = {}, arr, i = -1;
  4. t = t("forEach");
  5. t(
  6. o,
  7. function (value, name, self, index) {
  8. o2[name] = value;
  9. a(index, ++i, "Index");
  10. a(self, o, "Self");
  11. a(this, o3, "Scope");
  12. },
  13. o3
  14. );
  15. a.deep(o2, o);
  16. arr = [];
  17. o2 = {};
  18. i = -1;
  19. t(
  20. o,
  21. function (value, name, self, index) {
  22. arr.push(value);
  23. o2[name] = value;
  24. a(index, ++i, "Index");
  25. a(self, o, "Self");
  26. a(this, o3, "Scope");
  27. },
  28. o3,
  29. function (a, b) { return o[b] - o[a]; }
  30. );
  31. a.deep(o2, o, "Sort by Values: Content");
  32. a.deep(arr, [3, 2, 1], "Sort by Values: Order");
  33. };