UNPKG

snowflake-id-maker

Version:

Snowflake.io, generates k-ordered, conflict-free snowflake IDs in a distributed environment.

1 lines 2.63 kB
{"version":3,"file":"snowflake-id-maker.cjs","sources":["../../node_modules/.pnpm/bigint-conversion@2.4.3/node_modules/bigint-conversion/dist/esm/index.browser.js"],"sourcesContent":["import*as e from\"@juanelas/base64\";function n(e,n=!1,t){const r=e.match(/^(0x)?([\\da-fA-F]+)$/);if(null==r)throw new RangeError(\"input must be a hexadecimal string, e.g. '0x124fe3a' or '0214f1b2'\");let o=r[2];if(void 0!==t){if(t<o.length/2)throw new RangeError(`expected byte length ${t} < input hex byte length ${Math.ceil(o.length/2)}`);o=o.padStart(2*t,\"0\")}return n?\"0x\"+o:o}function t(e,n=!1){if(e<0)throw RangeError(\"a should be a non-negative integer. Negative values are not supported\");return l(o(e),n)}function r(e){let n=8n;ArrayBuffer.isView(e)?n=BigInt(8*e.BYTES_PER_ELEMENT):e=new Uint8Array(e);let t=0n;for(const r of e.values()){t=(t<<n)+BigInt(r)}return t}function o(e,t=!1,r){if(e<0)throw RangeError(\"a should be a non-negative integer. Negative values are not supported\");return n(e.toString(16),t,r)}function a(e){return BigInt(n(e,!0))}function i(e){if(e<0)throw RangeError(\"a should be a non-negative integer. Negative values are not supported\");return f(l(e.toString(16)))}function u(e){return a(g(c(e)))}function f(e){return(new TextDecoder).decode(new Uint8Array(e))}function c(e,n=!1){return(new TextEncoder).encode(e).buffer}function g(e,t=!1,r){{let o=\"\";const a=\"0123456789abcdef\";return(e=ArrayBuffer.isView(e)?new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)):new Uint8Array(e)).forEach((e=>{o+=a[e>>4]+a[15&e]})),n(o,t,r)}}function l(e,t=!1){let r=n(e);return r=n(e,!1,Math.ceil(r.length/2)),Uint8Array.from(r.match(/[\\da-fA-F]{2}/g).map((e=>parseInt(e,16)))).buffer}function s(n,r=!1,o=!0){return e.encode(t(n),r,o)}function d(n){return r(e.decode(n))}export{d as base64ToBigint,s as bigintToBase64,t as bigintToBuf,o as bigintToHex,i as bigintToText,r as bufToBigint,g as bufToHex,f as bufToText,a as hexToBigint,l as hexToBuf,n as parseHex,u as textToBigint,c as textToBuf};\n//# sourceMappingURL=index.browser.js.map\n"],"names":["r","e","n","ArrayBuffer","isView","BigInt","BYTES_PER_ELEMENT","Uint8Array","_step","t","_iterator","_createForOfIteratorHelper","values","s","done","value","err","f"],"mappings":"2vGA8DM,SAAUA,EAAaC,GAC3B,IAAIC,EAAO,GACPC,YAAYC,OAAOH,GAAMC,EAAOG,OAA+B,EAAxBJ,EAAIK,mBAC1CL,EAAM,IAAIM,WAAWN,GAE1B,IAC6CO,EADzCC,EAAM,GACVC,EAAAC,EAAiBV,EAA4BW,UAAA,IAA7C,IAAAF,EAAAG,MAAAL,EAAAE,EAAAR,KAAAY,MAAuD,CAAA,IAA5Cd,EAAAQ,EAAAO,MAETN,GAAOA,GAAOP,GADHG,OAAOL,EAEnB,CACD,CAAA,MAAAgB,GAAAN,EAAAT,EAAAe,EAAA,CAAA,QAAAN,EAAAO,GAAA,CAAA,OAAOR,CACT"}