* Computes a hash of an 'obj'. * Hash of a: * string is string * number is number as string * object is either result of calling $$hashKey function on the object or uniquely generated id, * that is also assigned to the $$hashKey property of the object. * * @param obj * @returns {s
(obj)
| 2226 | * The resulting string key is in 'type:hashKey' format. |
| 2227 | */ |
| 2228 | function hashKey(obj) { |
| 2229 | var objType = typeof obj, |
| 2230 | key; |
| 2231 | |
| 2232 | if (objType == 'object' && obj !== null) { |
| 2233 | if (typeof (key = obj.$$hashKey) == 'function') { |
| 2234 | // must invoke on object to keep the right this |
| 2235 | key = obj.$$hashKey(); |
| 2236 | } else if (key === undefined) { |
| 2237 | key = obj.$$hashKey = nextUid(); |
| 2238 | } |
| 2239 | } else { |
| 2240 | key = obj; |
| 2241 | } |
| 2242 | |
| 2243 | return objType + ':' + key; |
| 2244 | } |
| 2245 | |
| 2246 | /** |
| 2247 | * HashMap which can use objects as keys |