Front end of the Slack clone application.

polyfill.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. 'use strict';
  2. var aFrom = require('es5-ext/array/from')
  3. , toArray = require('es5-ext/array/to-array');
  4. module.exports = function (T, a) {
  5. var arr = ['raz', 'dwa', 'trzy'], set = new T(arr), x = {}, y = {}, i = 0;
  6. a(set instanceof T, true, "Set");
  7. a(set.size, 3, "Size");
  8. a(set.has('raz'), true, "Has: true");
  9. a(set.has(x), false, "Has: false");
  10. a(set.add(x), set, "Add: return");
  11. a(set.has(x), true, "Add");
  12. a(set.size, 4, "Add: Size");
  13. a(set.delete({}), false, "Delete: false");
  14. arr.push(x);
  15. set.forEach(function () {
  16. a.deep(aFrom(arguments), [arr[i], arr[i], set],
  17. "ForEach: Arguments: #" + i);
  18. a(this, y, "ForEach: Context: #" + i);
  19. if (i === 0) {
  20. a(set.delete('raz'), true, "Delete: true");
  21. a(set.has('raz'), false, "Delete");
  22. a(set.size, 3, "Delete: size");
  23. set.add('cztery');
  24. arr.push('cztery');
  25. }
  26. i++;
  27. }, y);
  28. arr.splice(0, 1);
  29. a.deep(toArray(set.entries()), [['dwa', 'dwa'], ['trzy', 'trzy'], [x, x],
  30. ['cztery', 'cztery']], "Entries");
  31. a.deep(toArray(set.keys()), ['dwa', 'trzy', x, 'cztery'], "Keys");
  32. a.deep(toArray(set.values()), ['dwa', 'trzy', x, 'cztery'], "Values");
  33. a.deep(toArray(set), ['dwa', 'trzy', x, 'cztery'], "Iterator");
  34. set.clear();
  35. a(set.size, 0, "Clear: size");
  36. a(set.has('trzy'), false, "Clear: has");
  37. a.deep(toArray(set), [], "Clear: Values");
  38. a.h1("Empty initialization");
  39. set = new T();
  40. set.add('foo');
  41. a(set.size, 1);
  42. a(set.has('foo'), true);
  43. };