UNPKG

@rickosborne/hexgrid

Version:

Rick Osborne's collection of hexagonal grid-related code.

23 lines (22 loc) 754 B
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); import { memoizeSupplier } from "@rickosborne/foundation"; const buffer64 = memoizeSupplier(() => Buffer.allocUnsafe(8)); const toBits32 = /* @__PURE__ */ __name((num, buf = buffer64(), offset = 0) => { if (Number.isSafeInteger(num)) { buf.writeInt32BE(num, offset); } else { buf.writeFloatBE(num, offset); } return buf.readUInt32BE(offset); }, "toBits32"); const qrsHashCode = /* @__PURE__ */ __name(({ q, r }) => { const buf = buffer64(); toBits32(q, buf, 0); toBits32(r, buf, 4); return buf.readBigUint64LE(); }, "qrsHashCode"); export { qrsHashCode }; //# sourceMappingURL=qrs-hash-code.mjs.map