a zip code crypto-currency system good for red ONLY

MapPolyfill.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. export class MapPolyfill {
  2. constructor() {
  3. this.size = 0;
  4. this._values = [];
  5. this._keys = [];
  6. }
  7. get(key) {
  8. const i = this._keys.indexOf(key);
  9. return i === -1 ? undefined : this._values[i];
  10. }
  11. set(key, value) {
  12. const i = this._keys.indexOf(key);
  13. if (i === -1) {
  14. this._keys.push(key);
  15. this._values.push(value);
  16. this.size++;
  17. }
  18. else {
  19. this._values[i] = value;
  20. }
  21. return this;
  22. }
  23. delete(key) {
  24. const i = this._keys.indexOf(key);
  25. if (i === -1) {
  26. return false;
  27. }
  28. this._values.splice(i, 1);
  29. this._keys.splice(i, 1);
  30. this.size--;
  31. return true;
  32. }
  33. clear() {
  34. this._keys.length = 0;
  35. this._values.length = 0;
  36. this.size = 0;
  37. }
  38. forEach(cb, thisArg) {
  39. for (let i = 0; i < this.size; i++) {
  40. cb.call(thisArg, this._values[i], this._keys[i]);
  41. }
  42. }
  43. }
  44. //# sourceMappingURL=MapPolyfill.js.map