_iterate.js 639 B

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