(obj)
| 60 | } |
| 61 | |
| 62 | export function hashcode(obj) { |
| 63 | let hash = 0, i, chr, len, str; |
| 64 | |
| 65 | let type = typeof obj; |
| 66 | switch (type) { |
| 67 | case 'object': |
| 68 | //let newObj = {}; |
| 69 | //forEach(obj, (v, k) => v && (typeof v === 'object' || 'function') ? v.toString() : v); |
| 70 | str = JSON.stringify(obj); |
| 71 | break; |
| 72 | case 'string': |
| 73 | str = obj; |
| 74 | break; |
| 75 | default: |
| 76 | str = obj.toString(); |
| 77 | break; |
| 78 | } |
| 79 | |
| 80 | if (str.length === 0) return hash; |
| 81 | for (i = 0, len = str.length; i < len; i++) { |
| 82 | chr = str.charCodeAt(i); |
| 83 | hash = ((hash << 5) - hash) + chr; |
| 84 | hash |= 0; // Convert to 32bit integer |
| 85 | } |
| 86 | return hash.toString(36); |
| 87 | } |
| 88 | |
| 89 | export function sortByKey (obj) { |
| 90 | if (!obj) { |
no outgoing calls
no test coverage detected
searching dependent graphs…