MCPcopy Index your code
hub / github.com/Lobos/react-ui / hashcode

Function hashcode

src/utils/objects.js:62–87  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

60}
61
62export 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
89export function sortByKey (obj) {
90 if (!obj) {

Callers 7

formatDataMethod · 0.90
formatDataFunction · 0.90
formatDataMethod · 0.90
renderBodyMethod · 0.90
renderControlsMethod · 0.90
setTplFunction · 0.90
toTextValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…