@necto/id 1.1.0 → 1.2.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 CHANGED
@@ -1,2 +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});
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
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +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"]}
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"]}
@@ -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 CHANGED
@@ -1,2 +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});
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
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.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 { 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"]}
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 CHANGED
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "name": "@necto/id",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
+ "type": "module",
4
5
  "description": "Necto's library for generating algorithmic ID's based on specified parameters.",
5
- "main": "index.js",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
6
8
  "files": [
7
9
  "dist",
8
10
  "README.md",