fantomid 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/fantomid.js +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22,7 +22,7 @@ function fantomid() {
|
|
|
22
22
|
for (let i = 0; i < RANDOM_BITS_LENGTH; i++) {
|
|
23
23
|
bits[RANDOM_BITS_LENGTH - 1 - i] = randomBytes[Math.floor(i / 8)] >> i % 8 & 1;
|
|
24
24
|
}
|
|
25
|
-
return Number("0b" + bits.
|
|
25
|
+
return Number("0b" + bits.join(""));
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
module.exports = fantomid;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/fantomid.js"],"sourcesContent":["import { random } from \"@lukeed/csprng\";\n\nconst EPOCH = new Date(\"2024-09-08\");\nconst TIMESTAMP_LENGTH = 36;\nconst RANDOM_BITS_LENGTH = 17;\nconst TIMESTAMP_PRECISION_DIVIDER = 100;\n\nexport function fantomid() {\n const bits = Array(TIMESTAMP_LENGTH + RANDOM_BITS_LENGTH);\n\n // Generates a timestamp to be part of the key. This is\n // inspired by how UUID v7 works: the idea is that this\n // will guarantee keys are generated evenly across time.\n const timestamp = Math.round(\n // Use a more recent base date instead of the Unix Epoch to\n // increase the amount of time we can represent in the timestamp.\n (Date.now() - EPOCH) /\n // Decrease the precision of the timestamp to\n // increase the amount of bits we can fit in a key.\n TIMESTAMP_PRECISION_DIVIDER,\n );\n for (let i = 0; i < TIMESTAMP_LENGTH; i++) {\n bits[TIMESTAMP_LENGTH + RANDOM_BITS_LENGTH - 1 - i] = (timestamp >> i) & 1;\n }\n\n // Generates a randomized part of the key. If multiple machines generate a\n // key at the exact same time (limited by the precision of the timestamp),\n // we are ensured to have a chance of collision of `1` in `2 ** RANDOM_BITS_LENGTH`.\n const randomBytes = random(Math.ceil(RANDOM_BITS_LENGTH / 8));\n for (let i = 0; i < RANDOM_BITS_LENGTH; i++) {\n bits[RANDOM_BITS_LENGTH - 1 - i] =\n (randomBytes[Math.floor(i / 8)] >> i % 8) & 1;\n }\n\n return Number(\"0b\" + bits.
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/fantomid.js"],"sourcesContent":["import { random } from \"@lukeed/csprng\";\n\nconst EPOCH = new Date(\"2024-09-08\");\nconst TIMESTAMP_LENGTH = 36;\nconst RANDOM_BITS_LENGTH = 17;\nconst TIMESTAMP_PRECISION_DIVIDER = 100;\n\nexport function fantomid() {\n const bits = Array(TIMESTAMP_LENGTH + RANDOM_BITS_LENGTH);\n\n // Generates a timestamp to be part of the key. This is\n // inspired by how UUID v7 works: the idea is that this\n // will guarantee keys are generated evenly across time.\n const timestamp = Math.round(\n // Use a more recent base date instead of the Unix Epoch to\n // increase the amount of time we can represent in the timestamp.\n (Date.now() - EPOCH) /\n // Decrease the precision of the timestamp to\n // increase the amount of bits we can fit in a key.\n TIMESTAMP_PRECISION_DIVIDER,\n );\n for (let i = 0; i < TIMESTAMP_LENGTH; i++) {\n bits[TIMESTAMP_LENGTH + RANDOM_BITS_LENGTH - 1 - i] = (timestamp >> i) & 1;\n }\n\n // Generates a randomized part of the key. If multiple machines generate a\n // key at the exact same time (limited by the precision of the timestamp),\n // we are ensured to have a chance of collision of `1` in `2 ** RANDOM_BITS_LENGTH`.\n const randomBytes = random(Math.ceil(RANDOM_BITS_LENGTH / 8));\n for (let i = 0; i < RANDOM_BITS_LENGTH; i++) {\n bits[RANDOM_BITS_LENGTH - 1 - i] =\n (randomBytes[Math.floor(i / 8)] >> i % 8) & 1;\n }\n\n return Number(\"0b\" + bits.join(\"\"));\n}\n"],"names":["random"],"mappings":";;;;AACA,MAAM,KAAK,mBAAmB,IAAI,IAAI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 1;
|
|
22
22
|
}
|
|
23
|
-
return Number("0b" + bits.
|
|
23
|
+
return Number("0b" + bits.join(""));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export { fantomid as default };
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/fantomid.js"],"sourcesContent":["import { random } from \"@lukeed/csprng\";\n\nconst EPOCH = new Date(\"2024-09-08\");\nconst TIMESTAMP_LENGTH = 36;\nconst RANDOM_BITS_LENGTH = 17;\nconst TIMESTAMP_PRECISION_DIVIDER = 100;\n\nexport function fantomid() {\n const bits = Array(TIMESTAMP_LENGTH + RANDOM_BITS_LENGTH);\n\n // Generates a timestamp to be part of the key. This is\n // inspired by how UUID v7 works: the idea is that this\n // will guarantee keys are generated evenly across time.\n const timestamp = Math.round(\n // Use a more recent base date instead of the Unix Epoch to\n // increase the amount of time we can represent in the timestamp.\n (Date.now() - EPOCH) /\n // Decrease the precision of the timestamp to\n // increase the amount of bits we can fit in a key.\n TIMESTAMP_PRECISION_DIVIDER,\n );\n for (let i = 0; i < TIMESTAMP_LENGTH; i++) {\n bits[TIMESTAMP_LENGTH + RANDOM_BITS_LENGTH - 1 - i] = (timestamp >> i) & 1;\n }\n\n // Generates a randomized part of the key. If multiple machines generate a\n // key at the exact same time (limited by the precision of the timestamp),\n // we are ensured to have a chance of collision of `1` in `2 ** RANDOM_BITS_LENGTH`.\n const randomBytes = random(Math.ceil(RANDOM_BITS_LENGTH / 8));\n for (let i = 0; i < RANDOM_BITS_LENGTH; i++) {\n bits[RANDOM_BITS_LENGTH - 1 - i] =\n (randomBytes[Math.floor(i / 8)] >> i % 8) & 1;\n }\n\n return Number(\"0b\" + bits.
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/fantomid.js"],"sourcesContent":["import { random } from \"@lukeed/csprng\";\n\nconst EPOCH = new Date(\"2024-09-08\");\nconst TIMESTAMP_LENGTH = 36;\nconst RANDOM_BITS_LENGTH = 17;\nconst TIMESTAMP_PRECISION_DIVIDER = 100;\n\nexport function fantomid() {\n const bits = Array(TIMESTAMP_LENGTH + RANDOM_BITS_LENGTH);\n\n // Generates a timestamp to be part of the key. This is\n // inspired by how UUID v7 works: the idea is that this\n // will guarantee keys are generated evenly across time.\n const timestamp = Math.round(\n // Use a more recent base date instead of the Unix Epoch to\n // increase the amount of time we can represent in the timestamp.\n (Date.now() - EPOCH) /\n // Decrease the precision of the timestamp to\n // increase the amount of bits we can fit in a key.\n TIMESTAMP_PRECISION_DIVIDER,\n );\n for (let i = 0; i < TIMESTAMP_LENGTH; i++) {\n bits[TIMESTAMP_LENGTH + RANDOM_BITS_LENGTH - 1 - i] = (timestamp >> i) & 1;\n }\n\n // Generates a randomized part of the key. If multiple machines generate a\n // key at the exact same time (limited by the precision of the timestamp),\n // we are ensured to have a chance of collision of `1` in `2 ** RANDOM_BITS_LENGTH`.\n const randomBytes = random(Math.ceil(RANDOM_BITS_LENGTH / 8));\n for (let i = 0; i < RANDOM_BITS_LENGTH; i++) {\n bits[RANDOM_BITS_LENGTH - 1 - i] =\n (randomBytes[Math.floor(i / 8)] >> i % 8) & 1;\n }\n\n return Number(\"0b\" + bits.join(\"\"));\n}\n"],"names":[],"mappings":";;AACA,MAAM,KAAK,mBAAmB,IAAI,IAAI,CAAC,YAAY,CAAC;AACpD,MAAM,gBAAgB,GAAG,EAAE;AAC3B,MAAM,kBAAkB,GAAG,EAAE;AAC7B,MAAM,2BAA2B,GAAG,GAAG;AAChC,SAAS,QAAQ,GAAG;AAC3B,EAAE,MAAM,IAAI,GAAG,KAAK,CAAC,gBAAgB,GAAG,kBAAkB,CAAC;AAC3D,EAAE,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK;AAC9B;AACA;AACA,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;AACvB;AACA,IAAI;AACJ,GAAG;AACH,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC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