const fnv = require("fnv-plus"); const bigInt = require("big-integer"); module.exports.ident =ident; module.exports.extractSizes =extractSizes; module.exports.flatArray = flatArray; module.exports.csArr = csArr; module.exports.accSizes = accSizes; module.exports.fnvHash = fnvHash; module.exports.stringifyBigInts = stringifyBigInts; module.exports.unstringifyBigInts = unstringifyBigInts; module.exports.sameSizes = sameSizes; module.exports.isDefined = isDefined; module.exports.accSizes2Str = accSizes2Str; function ident(text) { if (typeof text === "string") { let lines = text.split("\n"); for (let i=0; i=0; i--) { accSizes.unshift(accSizes[0]*sizes[i]); } return accSizes; } function fnvHash(str) { return fnv.hash(str, 64).hex(); } function stringifyBigInts(o) { if ((typeof(o) == "bigint") || o.eq !== undefined) { return o.toString(10); } else if (Array.isArray(o)) { return o.map(stringifyBigInts); } else if (typeof o == "object") { const res = {}; for (let k in o) { res[k] = stringifyBigInts(o[k]); } return res; } else { return o; } } function unstringifyBigInts(o) { if ((typeof(o) == "string") && (/^[0-9]+$/.test(o) )) { return bigInt(o); } else if (Array.isArray(o)) { return o.map(unstringifyBigInts); } else if (typeof o == "object") { const res = {}; for (let k in o) { res[k] = unstringifyBigInts(o[k]); } return res; } else { return bigInt(o); } } function sameSizes(s1, s2) { if (!Array.isArray(s1)) return false; if (!Array.isArray(s2)) return false; if (s1.length != s2.length) return false; for (let i=0; i