@necto/id 1.1.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/LICENSE +21 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Necto
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var u=(t,r)=>{for(var n in r)i(t,n,{get:r[n],enumerable:!0})},f=(t,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of g(r))!p.call(t,e)&&e!==n&&i(t,e,{get:()=>r[e],enumerable:!(o=s(r,e))||o.enumerable});return t};var c=t=>f(i({},"__esModule",{value:!0}),t);var A={};u(A,{generateId:()=>w});module.exports=c(A);var m=require("crypto"),a=require("@necto/constants");function w(t,r=a.ALPHABET_COMBINED){if(t<=0)throw new Error("Length must be a positive integer.");let n=r.length,o=new Uint8Array(t);return m.webcrypto.getRandomValues(o),Array.from(o).map(e=>r[e%n]).join("")}0&&(module.exports={generateId});
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.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 { webcrypto } from 'node:crypto';\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 generateId(length: number, 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 = new Uint8Array(length);\n webcrypto.getRandomValues(randomValues);\n\n return Array.from(randomValues)\n .map((value) => charset[value % charsetLength])\n .join('');\n}"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAQA,IAAAI,EAA0B,kBAC1BC,EAAkC,4BAQ3B,SAASH,EAAWI,EAAgBC,EAAoB,oBAA2B,CACxF,GAAID,GAAU,EACZ,MAAM,IAAI,MAAM,oCAAoC,EAGtD,IAAME,EAAgBD,EAAQ,OACxBE,EAAe,IAAI,WAAWH,CAAM,EAC1C,mBAAU,gBAAgBG,CAAY,EAE/B,MAAM,KAAKA,CAAY,EAC3B,IAAKC,GAAUH,EAAQG,EAAQF,CAAa,CAAC,EAC7C,KAAK,EAAE,CACZ","names":["index_exports","__export","generateId","__toCommonJS","import_node_crypto","import_constants","length","charset","charsetLength","randomValues","value"]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Generates a random ID of the specified length using the provided character set.
|
|
10
|
+
* @param length - The length of the ID to generate.
|
|
11
|
+
* @param charset - The character set to use for generating the ID (default: ALPHABET_COMBINED).
|
|
12
|
+
* @returns A randomly generated ID string.
|
|
13
|
+
*/
|
|
14
|
+
declare function id(length?: number, charset?: string[]): string;
|
|
15
|
+
|
|
16
|
+
export { id };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Generates a random ID of the specified length using the provided character set.
|
|
10
|
+
* @param length - The length of the ID to generate.
|
|
11
|
+
* @param charset - The character set to use for generating the ID (default: ALPHABET_COMBINED).
|
|
12
|
+
* @returns A randomly generated ID string.
|
|
13
|
+
*/
|
|
14
|
+
declare function id(length?: number, charset?: string[]): string;
|
|
15
|
+
|
|
16
|
+
export { id };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var g=(t,r)=>{for(var n in r)i(t,n,{get:r[n],enumerable:!0})},u=(t,r,n,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of p(r))!f.call(t,o)&&o!==n&&i(t,o,{get:()=>r[o],enumerable:!(e=s(r,o))||e.enumerable});return t};var c=t=>u(i({},"__esModule",{value:!0}),t);var A={};g(A,{id:()=>w});module.exports=c(A);var m=require("crypto"),a=require("@necto/constants");function w(t=21,r=a.ALPHABET_COMBINED){if(t<=0)throw new Error("Length must be a positive integer.");let n=r.length,e=new Uint8Array(t);return m.webcrypto.getRandomValues(e),Array.from(e).map(o=>r[o%n]).join("")}0&&(module.exports={id});
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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 { webcrypto } from 'node:crypto';\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 = new Uint8Array(length);\n webcrypto.getRandomValues(randomValues);\n\n return Array.from(randomValues)\n .map((value) => charset[value % charsetLength])\n .join('');\n}"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,QAAAE,IAAA,eAAAC,EAAAH,GCQA,IAAAI,EAA0B,kBAC1BC,EAAkC,4BAQ3B,SAASC,EAAGC,EAAiB,GAAIC,EAAoB,oBAA2B,CACrF,GAAID,GAAU,EACZ,MAAM,IAAI,MAAM,oCAAoC,EAGtD,IAAME,EAAgBD,EAAQ,OACxBE,EAAe,IAAI,WAAWH,CAAM,EAC1C,mBAAU,gBAAgBG,CAAY,EAE/B,MAAM,KAAKA,CAAY,EAC3B,IAAKC,GAAUH,EAAQG,EAAQF,CAAa,CAAC,EAC7C,KAAK,EAAE,CACZ","names":["index_exports","__export","id","__toCommonJS","import_node_crypto","import_constants","id","length","charset","charsetLength","randomValues","value"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{webcrypto as i}from"node:crypto";import{ALPHABET_COMBINED as m}from"@necto/constants";function p(r=21,t=m){if(r<=0)throw new Error("Length must be a positive integer.");let n=t.length,o=new Uint8Array(r);return i.getRandomValues(o),Array.from(o).map(e=>t[e%n]).join("")}export{p as id};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +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 { webcrypto } from 'node:crypto';\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 = new Uint8Array(length);\n webcrypto.getRandomValues(randomValues);\n\n return Array.from(randomValues)\n .map((value) => charset[value % charsetLength])\n .join('');\n}"],"mappings":"AAQA,OAAS,aAAAA,MAAiB,cAC1B,OAAS,qBAAAC,MAAyB,mBAQ3B,SAASC,EAAGC,EAAiB,GAAIC,EAAoBH,EAA2B,CACrF,GAAIE,GAAU,EACZ,MAAM,IAAI,MAAM,oCAAoC,EAGtD,IAAME,EAAgBD,EAAQ,OACxBE,EAAe,IAAI,WAAWH,CAAM,EAC1C,OAAAH,EAAU,gBAAgBM,CAAY,EAE/B,MAAM,KAAKA,CAAY,EAC3B,IAAKC,GAAUH,EAAQG,EAAQF,CAAa,CAAC,EAC7C,KAAK,EAAE,CACZ","names":["webcrypto","ALPHABET_COMBINED","id","length","charset","charsetLength","randomValues","value"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@necto/id",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Necto's library for generating algorithmic ID's based on specified parameters.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"README.md",
|
|
9
|
+
"package.json"
|
|
10
|
+
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"necto",
|
|
13
|
+
"corinvo",
|
|
14
|
+
"nectoutil"
|
|
15
|
+
],
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@necto/constants": "1.1.0"
|
|
18
|
+
},
|
|
19
|
+
"author": "Corinvo OSS Team",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^22.14.1",
|
|
23
|
+
"tsup": "^8.4.0"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup --minify",
|
|
27
|
+
"build:watch": "tsup --watch"
|
|
28
|
+
}
|
|
29
|
+
}
|