UNPKG

@bigmi/client

Version:

Reactive primitives for Bitcoin apps.

43 lines 1.26 kB
export function hashFn(queryKey) { return JSON.stringify(queryKey, (_, value) => { if (isPlainObject(value)) { return Object.keys(value) .sort() .reduce((result, key) => { result[key] = value[key]; return result; }, {}); } if (typeof value === 'bigint') { return value.toString(); } return value; }); } // biome-ignore lint/complexity/noBannedTypes: function isPlainObject(value) { if (!hasObjectPrototype(value)) { return false; } // If has modified constructor const ctor = value.constructor; if (typeof ctor === 'undefined') { return true; } // If has modified prototype const prot = ctor.prototype; if (!hasObjectPrototype(prot)) { return false; } // If constructor does not have an Object-specific method // biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation> if (!prot.hasOwnProperty('isPrototypeOf')) { return false; } // Most likely a plain Object return true; } function hasObjectPrototype(o) { return Object.prototype.toString.call(o) === '[object Object]'; } //# sourceMappingURL=utils.js.map