random-indian-names 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 +21 -0
- package/README.md +45 -0
- package/index.js +145 -0
- package/package.json +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
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/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Random Indian Name Generator
|
|
2
|
+
|
|
3
|
+
A high-quality, lightweight Node.js module that uses a **Syllable Graph Engine** to generate authentic Indian names.
|
|
4
|
+
|
|
5
|
+
Instead of random letters, this module uses real cultural "roots" and "transitions" to ensure names are phonetically natural, unique, and accurate.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
- **Generative Algorithm**: Infinite variety, no stale datasets.
|
|
9
|
+
- **Length Control**: Specify `min` and `max` character counts.
|
|
10
|
+
- **Lightweight**: Zero dependencies.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
```bash
|
|
14
|
+
npm install random-indian-names
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Simple Name
|
|
20
|
+
Generate a random name with default length (3 to 10 characters).
|
|
21
|
+
```javascript
|
|
22
|
+
const { getRandomName } = require('random-indian-names');
|
|
23
|
+
|
|
24
|
+
// Generate a random name (3 to 10 characters default)
|
|
25
|
+
console.log(getRandomName()); // e.g., "Arjun"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### With Length Constraints
|
|
29
|
+
Get a name between 3 and 5 characters.
|
|
30
|
+
```javascript
|
|
31
|
+
console.log(getRandomName(3, 5)); // e.g., "Aditi"
|
|
32
|
+
|
|
33
|
+
// call with one parameter (min=5, max defaults to 10)
|
|
34
|
+
console.log(getRandomName(5)); // e.g., "Vihaan"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
### `getRandomName(min, max)`
|
|
40
|
+
- `min` (Number): Minimum character length (default: 3).
|
|
41
|
+
- `max` (Number): Maximum character length (default: 10).
|
|
42
|
+
- **Returns**: A capitalized string.
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Random Indian Name Generator
|
|
3
|
+
* Syllable Graph Engine - Refined transitions with repetition guards.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const syllableGraph = {
|
|
7
|
+
"starts": [
|
|
8
|
+
"A", "Ad", "Ak", "Am", "An", "Ar", "As", "Av", "Bha", "Cha", "De",
|
|
9
|
+
"Dha", "Ga", "Ha", "In", "Is", "Ja", "Ka", "Ki", "Ku", "La", "Ma",
|
|
10
|
+
"Mo", "Na", "Ni", "Pa", "Pr", "Ra", "Ri", "Ro", "Sa", "Sh", "Si",
|
|
11
|
+
"Su", "Ta", "Va", "Vi", "Ya", "U", "Yash"
|
|
12
|
+
],
|
|
13
|
+
"transitions": {
|
|
14
|
+
"A": ["mit", "kash", "nand", "jay", "dit", "vin", "run", "rav", "mrut", "man"],
|
|
15
|
+
"Ad": ["it", "iti", "ity", "vait"],
|
|
16
|
+
"Ak": ["ash", "shay", "rit"],
|
|
17
|
+
"Am": ["it", "rit", "ar", "an", "al"],
|
|
18
|
+
"An": ["it", "il", "and", "ish", "any", "uj", "ush"],
|
|
19
|
+
"Ar": ["un", "pit", "nav", "jun", "adh", "ind"],
|
|
20
|
+
"As": ["ha", "hish", "hok", "mita"],
|
|
21
|
+
"Av": ["i", "in", "inash"],
|
|
22
|
+
"Bha": ["rat", "nu", "vya", "kar"],
|
|
23
|
+
"Cha": ["it", "nd", "dan"],
|
|
24
|
+
"De": ["ep", "v", "van", "va"],
|
|
25
|
+
"Dha": ["ru", "nu", "nush", "v"],
|
|
26
|
+
"Ga": ["nesh", "ur", "tam", "yatri"],
|
|
27
|
+
"Ha": ["ri", "man", "rdik", "rish"],
|
|
28
|
+
"In": ["der", "di", "dra"],
|
|
29
|
+
"Is": ["ha", "han", "hani", "hit"],
|
|
30
|
+
"Ja": ["i", "tin", "ya", "tesh"],
|
|
31
|
+
"Ka": ["ran", "mal", "mita", "vita", "rtik"],
|
|
32
|
+
"Ki": ["ran", "shore"],
|
|
33
|
+
"Ku": ["nal", "mar", "ush"],
|
|
34
|
+
"La": ["lit", "kesh", "man"],
|
|
35
|
+
"Ma": ["dhav", "hesh", "nas", "nov", "noj", "ni"],
|
|
36
|
+
"Mo": ["han", "hit", "ni"],
|
|
37
|
+
"Na": ["man", "veen", "vya", "yan", "ndini"],
|
|
38
|
+
"Ni": ["khil", "ti", "dhi", "lesh", "raj"],
|
|
39
|
+
"Pa": ["kash", "raj", "nkaj", "rth", "yal"],
|
|
40
|
+
"Pr": ["ad", "ak", "am", "an", "at", "av", "it"],
|
|
41
|
+
"Ra": ["j", "jan", "jat", "hul", "m", "vi", "kesh"],
|
|
42
|
+
"Ri": ["shi", "tesh", "ya", "v"],
|
|
43
|
+
"Ro": ["han", "hit", "shni"],
|
|
44
|
+
"Sa": ["chin", "gar", "hil", "mir", "njay"],
|
|
45
|
+
"Sh": ["iv", "ivam", "ubh", "reya", "rut"],
|
|
46
|
+
"Si": ["d", "mran", "dharth"],
|
|
47
|
+
"Su": ["nil", "mit", "raj", "resh", "man"],
|
|
48
|
+
"Ta": ["run", "nmay", "nu"],
|
|
49
|
+
"Va": ["run", "ibhav", "ish"],
|
|
50
|
+
"Vi": ["jay", "nay", "nod", "shal", "vek"],
|
|
51
|
+
"Ya": ["sh", "ti", "min"],
|
|
52
|
+
"U": ["day", "ma", "rvi", "tk"]
|
|
53
|
+
},
|
|
54
|
+
// Special high-quality suffixes for longer names
|
|
55
|
+
"suffixes": ["kumar", "endra", "deep", "jeet", "prasad", "nath", "veer", "wati", "it", "esh", "an"]
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
function getRandom(arr) {
|
|
59
|
+
if (!arr || arr.length === 0) return "";
|
|
60
|
+
return arr[Math.floor(Math.random() * arr.length)];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getRandomName(min = 3, max = 10) {
|
|
64
|
+
if (typeof min !== 'number' || typeof max !== 'number') {
|
|
65
|
+
throw new Error("getRandomName requires numbers for min and max");
|
|
66
|
+
}
|
|
67
|
+
if (min > max) {
|
|
68
|
+
throw new Error("minimum letters cannot be greater than maximum letters");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let attempts = 0;
|
|
72
|
+
while (attempts < 500) {
|
|
73
|
+
let name = getRandom(syllableGraph.starts);
|
|
74
|
+
let usedSyllables = new Set([name.toLowerCase()]);
|
|
75
|
+
|
|
76
|
+
// Decide target length (favoring longer if min > 5)
|
|
77
|
+
const targetLength = max > 6 ?
|
|
78
|
+
Math.floor(Math.random() * (max - min + 1) + min) :
|
|
79
|
+
(Math.random() > 0.3 ? max : Math.max(min, 4));
|
|
80
|
+
|
|
81
|
+
let lastSyllable = name;
|
|
82
|
+
while (name.length < targetLength) {
|
|
83
|
+
const pool = syllableGraph.transitions[lastSyllable] ||
|
|
84
|
+
syllableGraph.transitions[name.slice(-2)] ||
|
|
85
|
+
syllableGraph.transitions[name.slice(-1)];
|
|
86
|
+
|
|
87
|
+
if (!pool) break;
|
|
88
|
+
|
|
89
|
+
// Pick a non-repetitive syllable
|
|
90
|
+
let next = getRandom(pool);
|
|
91
|
+
let subAttempts = 0;
|
|
92
|
+
while (usedSyllables.has(next.toLowerCase()) && subAttempts < 5) {
|
|
93
|
+
next = getRandom(pool);
|
|
94
|
+
subAttempts++;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (usedSyllables.has(next.toLowerCase())) break; // Avoid infinite loops
|
|
98
|
+
|
|
99
|
+
name += next;
|
|
100
|
+
usedSyllables.add(next.toLowerCase());
|
|
101
|
+
lastSyllable = next;
|
|
102
|
+
|
|
103
|
+
// Chance to attach a high-quality suffix if we are near target length
|
|
104
|
+
if (name.length >= targetLength - 4 && Math.random() > 0.6) {
|
|
105
|
+
const suffix = getRandom(syllableGraph.suffixes);
|
|
106
|
+
if (!usedSyllables.has(suffix.toLowerCase())) {
|
|
107
|
+
name += suffix;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Clean up and normalization
|
|
114
|
+
name = name.toLowerCase();
|
|
115
|
+
|
|
116
|
+
// Clean double vowels but PRESERVE 'ee' and 'oo' as they are common in Indian names (e.g., Deep, Jeet)
|
|
117
|
+
name = name.replace(/([aeiou])\1/gi, (match) => {
|
|
118
|
+
const low = match.toLowerCase();
|
|
119
|
+
return (low === 'ee' || low === 'oo') ? match : match[0];
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Remove impossible triple consonants
|
|
123
|
+
name = name.replace(/([^aeiou])\1\1/gi, '$1$1');
|
|
124
|
+
|
|
125
|
+
// Fix "Utktk" and similar issues by preventing identical vowel-less clusters
|
|
126
|
+
name = name.replace(/(tk|rt|rk)\1/gi, '$1');
|
|
127
|
+
|
|
128
|
+
if (name.length >= min && name.length <= max) {
|
|
129
|
+
// Capitalize
|
|
130
|
+
const result = name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
|
|
131
|
+
// Final authenticity check: Must not look like gibberish
|
|
132
|
+
if (!/([^aeiou]){4,}/i.test(result)) {
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
attempts++;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// High Quality Fallback (100% Correct)
|
|
140
|
+
const fallback = ["Amit", "Akash", "Aditi", "Arjun", "Kiran", "Nayan", "Vihaan", "Sania"];
|
|
141
|
+
const valid = fallback.filter(n => n.length >= min && n.length <= max);
|
|
142
|
+
return getRandom(valid.length > 0 ? valid : ["Amit"]);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
module.exports = { getRandomName };
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "random-indian-names",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "High-quality, syllable-based random Indian name generator for Node.js.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"index.js",
|
|
8
|
+
"README.md",
|
|
9
|
+
"LICENSE"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "node test.js"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"indian",
|
|
16
|
+
"names",
|
|
17
|
+
"generator",
|
|
18
|
+
"syllable-graph",
|
|
19
|
+
"random-names",
|
|
20
|
+
"faker",
|
|
21
|
+
"mock-data"
|
|
22
|
+
],
|
|
23
|
+
"author": "Ashik A Jain",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"type": "commonjs"
|
|
26
|
+
}
|