MCPcopy Create free account
hub / github.com/CashScript/cashscript / extendedStringify

Function extendedStringify

packages/cashscript/src/utils.ts:420–432  ·  view source on GitHub ↗
(obj: any, spaces?: number)

Source from the content-addressed store, hash-verified

418
419// JSON.stringify version that can serialize otherwise unsupported types (bigint and Uint8Array)
420export const extendedStringify = (obj: any, spaces?: number): string => JSON.stringify(
421 obj,
422 (_, v) => {
423 if (typeof v === 'bigint') {
424 return `${v.toString()}`;
425 }
426 if (v instanceof Uint8Array) {
427 return `${binToHex(v)}`;
428 }
429 return v;
430 },
431 spaces,
432);
433
434export const zip = <T, U>(a: readonly T[], b: readonly U[]): [T, U][] => (
435 Array.from(Array(Math.max(b.length, a.length)), (_, i) => [a[i], b[i]])

Callers 1

getBitauthUriFunction · 0.85

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected