Requires

Provides

Contains Hash Prototypes. Provides a means for overcoming the JavaScript practical impossibility of extending native Objects.

License:
MIT-style license.
  1. 20
  2. 21
  3. 22
  4. 23
  5. 24
  6. 25
  7. 26
  8. 27
  9. 28
  10. 29
  11. 30
  12. 31
  13. 32
  14. 33
  15. 34
  16. 35
  17. 36
  18. 37
  19. 38
  20. 39
  21. 40
  22. 41
  23. 42
  24. 43
  25. 44
  26. 45
  27. 46
  28. 47
  29. 48
  30. 49
  31. 50
  32. 51
  33. 52
  34. 53
  35. 54
  36. 55
  37. 56
  38. 57
  39. 58
  40. 59
  41. 60
  42. 61
  43. 62
  44. 63
  45. 64
  46. 65
  47. 66
  48. 67
  49. 68
  50. 69
  51. 70
  52. 71
  53. 72
  54. 73
  55. 74
  56. 75
  57. 76
  58. 77
  59. 78
  60. 79
  61. 80
  62. 81
  63. 82
  64. 83
  65. 84
  66. 85
  67. 86
  68. 87
  69. 88
  70. 89
  71. 90
  72. 91
  73. 92
  74. 93
  75. 94
  76. 95
  77. 96
  78. 97
  79. 98
  80. 99
  81. 100
  82. 101
  83. 102
  84. 103
  85. 104
  86. 105
  87. 106
  88. 107
  89. 108
  90. 109
  91. 110
  92. 111
  93. 112
  94. 113
  95. 114
  96. 115
  97. 116
  98. 117
  99. 118
  100. 119
  101. 120
  102. 121
  103. 122
  104. 123
  105. 124
  106. 125
  107. 126
  108. 127
  109. 128
  110. 129
  111. 130
  112. 131
  113. 132
  114. 133
  115. 134
  116. 135
  117. 136
  118. 137
  119. 138
  120. 139
  121. 140
  122. 141
  123. 142
  124. 143
  125. 144
  126. 145
(function(){ if (this.Hash) return; var Hash = this.Hash = new Type('Hash', function(object){ if (typeOf(object) == 'hash') object = Object.clone(object.getClean()); for (var key in object) this[key] = object[key]; return this; }); this.$H = function(object){ return new Hash(object); }; Hash.implement({ forEach: function(fn, bind){ Object.forEach(this, fn, bind); }, getClean: function(){ var clean = {}; for (var key in this){ if (this.hasOwnProperty(key)) clean[key] = this[key]; } return clean; }, getLength: function(){ var length = 0; for (var key in this){ if (this.hasOwnProperty(key)) length++; } return length; } }); Hash.alias('each', 'forEach'); Hash.implement({ has: Object.prototype.hasOwnProperty, keyOf: function(value){ return Object.keyOf(this, value); }, hasValue: function(value){ return Object.contains(this, value); }, extend: function(properties){ Hash.each(properties || {}, function(value, key){ Hash.set(this, key, value); }, this); return this; }, combine: function(properties){ Hash.each(properties || {}, function(value, key){ Hash.include(this, key, value); }, this); return this; }, erase: function(key){ if (this.hasOwnProperty(key)) delete this[key]; return this; }, get: function(key){ return (this.hasOwnProperty(key)) ? this[key] : null; }, set: function(key, value){ if (!this[key] || this.hasOwnProperty(key)) this[key] = value; return this; }, empty: function(){ Hash.each(this, function(value, key){ delete this[key]; }, this); return this; }, include: function(key, value){ if (this[key] == undefined) this[key] = value; return this; }, map: function(fn, bind){ return new Hash(Object.map(this, fn, bind)); }, filter: function(fn, bind){ return new Hash(Object.filter(this, fn, bind)); }, every: function(fn, bind){ return Object.every(this, fn, bind); }, some: function(fn, bind){ return Object.some(this, fn, bind); }, getKeys: function(){ return Object.keys(this); }, getValues: function(){ return Object.values(this); }, toQueryString: function(base){ return Object.toQueryString(this, base); } }); Hash.alias({indexOf: 'keyOf', contains: 'hasValue'}); })();