MCPcopy Create free account
hub / github.com/corbanbrook/dsp.js / virtHashCode

Function virtHashCode

examples/js/processing.js:3620–3637  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

3618 ////////////////////////////////////////////////////////////////////////////
3619
3620 var virtHashCode = function virtHashCode(obj) {
3621 if (obj.constructor === String) {
3622 var hash = 0;
3623 for (var i = 0; i < obj.length; ++i) {
3624 hash = (hash * 31 + obj.charCodeAt(i)) & 0xFFFFFFFF;
3625 }
3626 return hash;
3627 } else if (typeof(obj) !== "object") {
3628 return obj & 0xFFFFFFFF;
3629 } else if ("hashCode" in obj) {
3630 return obj.hashCode.call(obj);
3631 } else {
3632 if (obj.$id === undef) {
3633 obj.$id = ((Math.floor(Math.random() * 0x10000) - 0x8000) << 16) | Math.floor(Math.random() * 0x10000);
3634 }
3635 return obj.$id;
3636 }
3637 };
3638
3639 var virtEquals = function virtEquals(obj, other) {
3640 if (obj === null || other === null) {

Callers 3

ensureLoadFunction · 0.85
EntryFunction · 0.85
processing.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected