genkode 1.0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sammit Pal
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 do so, subject to the
10
+ 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/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # genkode
2
+
3
+ ![npm version](https://img.shields.io/npm/v/genkode)
4
+ ![npm downloads](https://img.shields.io/npm/dw/genkode)
5
+ ![license](https://img.shields.io/npm/l/genkode)
6
+ ![types](https://img.shields.io/npm/types/genkode)
7
+
8
+
9
+ A lightweight Node.js utility to generate random alphanumeric, alphabetic, or numeric strings.
10
+ Fully compatible with TypeScript. No external dependencies.
11
+
12
+ ---
13
+
14
+ ## 📦 Installation
15
+
16
+ ```bash
17
+ npm install genkode
18
+ ```
19
+
20
+ ---
21
+
22
+ ## 🚀 Usage
23
+
24
+ ### 1. Generate Alphanumeric String
25
+
26
+ ```ts
27
+ import { mumble } from 'genkode';
28
+
29
+ console.log(mumble(12));
30
+
31
+ // Example output:
32
+ // vl6QLrr3xIBe
33
+ ```
34
+
35
+ ---
36
+
37
+ ### 2. Generate Alphabet-only String
38
+
39
+ ```ts
40
+ import { mumblealpha } from 'genkode';
41
+
42
+ console.log(mumblealpha(12));
43
+
44
+ // Example output:
45
+ // rqfvYxJRWfoP
46
+ ```
47
+
48
+ ---
49
+
50
+ ### 3. Generate Numeric String
51
+
52
+ ```ts
53
+ import { mumblenum } from 'genkode';
54
+
55
+ console.log(mumblenum(12));
56
+
57
+ // Example output:
58
+ // 362128126198
59
+ ```
60
+
61
+ ---
62
+
63
+ ## ⚙️ API
64
+
65
+ | Function | Description |
66
+ |----------------|--------------------------------------|
67
+ | `mumble(n)` | Returns alphanumeric string |
68
+ | `mumblealpha(n)`| Returns alphabet-only string |
69
+ | `mumblenum(n)` | Returns numeric string |
70
+
71
+ - `n` → Length of the required string
72
+
73
+ ---
74
+
75
+ ## 🧩 Use Cases
76
+
77
+ These generated strings can be used for:
78
+
79
+ - Database IDs
80
+ - Tokens / API keys
81
+ - Session identifiers
82
+ - Temporary codes
83
+ - Random test data
84
+
85
+ ---
86
+
87
+ ## 🔒 Notes
88
+
89
+ - This package uses standard random generation (`Math.random`)
90
+ - Suitable for general-purpose use
91
+ - Not recommended for cryptographic/security-critical use cases
92
+
93
+ ---
94
+
95
+ ## 🔗 Related Package
96
+
97
+ This package is also available as a JavaScript-only version:
98
+
99
+ **node-mumble** (by the same developer)
100
+ https://www.npmjs.com/package/node-mumble
101
+
102
+ ---
103
+
104
+ ## 📄 License
105
+
106
+ ISC
@@ -0,0 +1,4 @@
1
+ export declare function mumble(input: number): string;
2
+ export declare function mumbleaplha(input: number): string;
3
+ export declare function mumblenum(input: number): string;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAWA,wBAAgB,MAAM,CAAC,KAAK,EAAC,MAAM,GAAE,MAAM,CAS1C;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAC,MAAM,GAAG,MAAM,CAWhD;AACD,wBAAgB,SAAS,CAAC,KAAK,EAAC,MAAM,GAAG,MAAM,CAW9C"}
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ const arr = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
2
+ function isLetter(s) {
3
+ return s.match("^[a-zA-Z\(\)]+$");
4
+ }
5
+ function isNumeric(s) {
6
+ return s.match("^[0-9\(\)]+$");
7
+ }
8
+ export function mumble(input) {
9
+ let uniqString = "";
10
+ const length = arr.length;
11
+ while (input != 0) {
12
+ const randomIndex = Math.floor(Math.random() * length);
13
+ uniqString = uniqString + arr[randomIndex];
14
+ input = input - 1;
15
+ }
16
+ return uniqString;
17
+ }
18
+ export function mumbleaplha(input) {
19
+ let uniqString = "";
20
+ const length = arr.length;
21
+ while (input != 0) {
22
+ const randomIndex = Math.floor(Math.random() * length);
23
+ if (isLetter(arr[randomIndex])) {
24
+ uniqString = uniqString + arr[randomIndex];
25
+ input = input - 1;
26
+ }
27
+ }
28
+ return uniqString;
29
+ }
30
+ export function mumblenum(input) {
31
+ let uniqString = "";
32
+ const length = arr.length;
33
+ while (input != 0) {
34
+ const randomIndex = Math.floor(Math.random() * length);
35
+ if (isNumeric(arr[randomIndex])) {
36
+ uniqString = uniqString + arr[randomIndex];
37
+ input = input - 1;
38
+ }
39
+ }
40
+ return uniqString;
41
+ }
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRo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","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];
2
+
3
+ function isLetter(s:string)
4
+ {
5
+ return s.match("^[a-zA-Z\(\)]+$");
6
+ }
7
+ function isNumeric(s:string)
8
+ {
9
+ return s.match("^[0-9\(\)]+$");
10
+ }
11
+
12
+ export function mumble(input:number):string {
13
+ let uniqString = "";
14
+ const length = arr.length
15
+ while (input!=0) {
16
+ const randomIndex = Math.floor(Math.random()*length)
17
+ uniqString = uniqString+arr[randomIndex];
18
+ input = input - 1;
19
+ }
20
+ return uniqString
21
+ }
22
+
23
+ export function mumbleaplha(input:number): string {
24
+ let uniqString = "";
25
+ const length = arr.length
26
+ while (input!=0) {
27
+ const randomIndex = Math.floor(Math.random()*length)
28
+ if(isLetter(arr[randomIndex]!)){
29
+ uniqString = uniqString+arr[randomIndex];
30
+ input = input - 1;
31
+ }
32
+ }
33
+ return uniqString
34
+ }
35
+ export function mumblenum(input:number): string {
36
+ let uniqString = "";
37
+ const length = arr.length
38
+ while (input!=0) {
39
+ const randomIndex = Math.floor(Math.random()*length)
40
+ if(isNumeric(arr[randomIndex]!)){
41
+ uniqString = uniqString+arr[randomIndex];
42
+ input = input - 1;
43
+ }
44
+ }
45
+ return uniqString
46
+ }
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "genkode",
3
+ "version": "1.0.0",
4
+ "description": "A node package that creates a random unique characters string (Typescript Supported)",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/sammitpal/genkode.git"
10
+ },
11
+ "type": "module",
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "keywords": [
17
+ "random",
18
+ "string",
19
+ "generator",
20
+ "id",
21
+ "token",
22
+ "alphanumeric"
23
+ ],
24
+ "author": "",
25
+ "license": "MIT",
26
+ "devDependencies": {
27
+ "typescript": "^6.0.2"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/sammitpal/genkode/issues"
31
+ },
32
+ "homepage": "https://github.com/sammitpal/genkode#readme"
33
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": ".",
4
+ "outDir": "./dist",
5
+
6
+ "module": "nodenext",
7
+ "target": "esnext",
8
+ "types": [],
9
+
10
+ "sourceMap": true,
11
+ "declaration": true,
12
+ "declarationMap": true,
13
+
14
+ "noUncheckedIndexedAccess": true,
15
+ "exactOptionalPropertyTypes": true,
16
+
17
+
18
+ "strict": true,
19
+ "verbatimModuleSyntax": true,
20
+ "isolatedModules": true,
21
+ "noUncheckedSideEffectImports": true,
22
+ "moduleDetection": "force",
23
+ "skipLibCheck": true,
24
+ }
25
+ }