@necto/id 1.2.0 → 1.3.0
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.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var
|
|
1
|
+
"use strict";var f=Object.create;var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var d=(r,o)=>{for(var t in o)i(r,t,{get:o[t],enumerable:!0})},m=(r,o,t,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of g(o))!c.call(r,n)&&n!==t&&i(r,n,{get:()=>o[n],enumerable:!(e=p(o,n))||e.enumerable});return r};var h=(r,o,t)=>(t=r!=null?f(u(r)):{},m(o||!r||!r.__esModule?i(t,"default",{value:r,enumerable:!0}):t,r)),A=r=>m(i({},"__esModule",{value:!0}),r);var E={};d(E,{id:()=>B});module.exports=A(E);var s=h(require("randombytes"),1),a=require("@necto/constants");function B(r=21,o=a.ALPHABET_COMBINED){if(r<=0)throw new Error("Length must be a positive integer.");let t=o.length,e=(0,s.default)(r);return Array.from(e).map(n=>o[n%t]).join("")}0&&(module.exports={id});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/id.ts"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport * from \"./id\";","/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/id.ts"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nexport * from \"./id\";","/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport randomBytes from 'randombytes';\nimport { ALPHABET_COMBINED } from '@necto/constants';\n\n/**\n * Generates a random ID of the specified length using the provided character set.\n * @param length - The length of the ID to generate.\n * @param charset - The character set to use for generating the ID (default: ALPHABET_COMBINED).\n * @returns A randomly generated ID string.\n */\nexport function id(length: number = 21, charset: string[] = ALPHABET_COMBINED): string {\n if (length <= 0) {\n throw new Error('Length must be a positive integer.');\n }\n\n const charsetLength = charset.length;\n const randomValues = randomBytes(length);\n\n return Array.from(randomValues)\n .map((value) => charset[value % charsetLength])\n .join('');\n}"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,QAAAE,IAAA,eAAAC,EAAAH,GCQA,IAAAI,EAAwB,4BACxBC,EAAkC,4BAQ3B,SAASC,EAAGC,EAAiB,GAAIC,EAAoB,oBAA2B,CACrF,GAAID,GAAU,EACZ,MAAM,IAAI,MAAM,oCAAoC,EAGtD,IAAME,EAAgBD,EAAQ,OACxBE,KAAe,EAAAC,SAAYJ,CAAM,EAEvC,OAAO,MAAM,KAAKG,CAAY,EAC3B,IAAKE,GAAUJ,EAAQI,EAAQH,CAAa,CAAC,EAC7C,KAAK,EAAE,CACZ","names":["index_exports","__export","id","__toCommonJS","import_randombytes","import_constants","id","length","charset","charsetLength","randomValues","randomBytes","value"]}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import i from"randombytes";import{ALPHABET_COMBINED as m}from"@necto/constants";function f(r=21,o=m){if(r<=0)throw new Error("Length must be a positive integer.");let t=o.length,n=i(r);return Array.from(n).map(e=>o[e%t]).join("")}export{f as id};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/id.ts"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport
|
|
1
|
+
{"version":3,"sources":["../src/id.ts"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport randomBytes from 'randombytes';\nimport { ALPHABET_COMBINED } from '@necto/constants';\n\n/**\n * Generates a random ID of the specified length using the provided character set.\n * @param length - The length of the ID to generate.\n * @param charset - The character set to use for generating the ID (default: ALPHABET_COMBINED).\n * @returns A randomly generated ID string.\n */\nexport function id(length: number = 21, charset: string[] = ALPHABET_COMBINED): string {\n if (length <= 0) {\n throw new Error('Length must be a positive integer.');\n }\n\n const charsetLength = charset.length;\n const randomValues = randomBytes(length);\n\n return Array.from(randomValues)\n .map((value) => charset[value % charsetLength])\n .join('');\n}"],"mappings":"AAQA,OAAOA,MAAiB,cACxB,OAAS,qBAAAC,MAAyB,mBAQ3B,SAASC,EAAGC,EAAiB,GAAIC,EAAoBH,EAA2B,CACrF,GAAIE,GAAU,EACZ,MAAM,IAAI,MAAM,oCAAoC,EAGtD,IAAME,EAAgBD,EAAQ,OACxBE,EAAeN,EAAYG,CAAM,EAEvC,OAAO,MAAM,KAAKG,CAAY,EAC3B,IAAKC,GAAUH,EAAQG,EAAQF,CAAa,CAAC,EAC7C,KAAK,EAAE,CACZ","names":["randomBytes","ALPHABET_COMBINED","id","length","charset","charsetLength","randomValues","value"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@necto/id",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Necto's library for generating algorithmic ID's based on specified parameters.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,8 +22,12 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^22.14.1",
|
|
25
|
+
"@types/randombytes": "^2.0.3",
|
|
25
26
|
"tsup": "^8.4.0"
|
|
26
27
|
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"randombytes": "^2.1.0"
|
|
30
|
+
},
|
|
27
31
|
"scripts": {
|
|
28
32
|
"build": "tsup --minify",
|
|
29
33
|
"build:watch": "tsup --watch"
|