vietnamese-name-generator 0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 hungnguyen
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,177 @@
1
+ # vietnamese-name-generator
2
+
3
+ [![npm version](https://img.shields.io/npm/v/vietnamese-name-generator)](https://www.npmjs.com/package/vietnamese-name-generator)
4
+ [![npm downloads](https://img.shields.io/npm/dm/vietnamese-name-generator)](https://www.npmjs.com/package/vietnamese-name-generator)
5
+ [![CI](https://github.com/hungnguyen18/vietnamese-name-generator/actions/workflows/ci.yml/badge.svg)](https://github.com/hungnguyen18/vietnamese-name-generator/actions/workflows/ci.yml)
6
+ [![license](https://img.shields.io/npm/l/vietnamese-name-generator)](./LICENSE)
7
+
8
+ Generate realistic Vietnamese names with gender, region, era, and meaning filtering.
9
+
10
+ Surnames are weighted by census frequency. Regional dialects are respected (Hoàng/Huỳnh, Vũ/Võ). Names carry real semantic meaning across 9 categories. Zero runtime dependencies. Ships as CJS + ESM with full TypeScript declarations.
11
+
12
+ ## Installation
13
+
14
+ **npm**
15
+
16
+ ```bash
17
+ npm install vietnamese-name-generator
18
+ ```
19
+
20
+ **pnpm**
21
+
22
+ ```bash
23
+ pnpm add vietnamese-name-generator
24
+ ```
25
+
26
+ **yarn**
27
+
28
+ ```bash
29
+ yarn add vietnamese-name-generator
30
+ ```
31
+
32
+ **bun**
33
+
34
+ ```bash
35
+ bun add vietnamese-name-generator
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```typescript
41
+ import {
42
+ generate,
43
+ generateMany,
44
+ generateFullName,
45
+ generateManyFullNames,
46
+ EGender,
47
+ ERegion,
48
+ EEra,
49
+ EMeaningCategory,
50
+ } from "vietnamese-name-generator";
51
+
52
+ // Single name — full metadata
53
+ const name = generate();
54
+ console.log(name.fullName); // 'Nguyễn Thị Lan'
55
+ console.log(name.surname); // 'Nguyễn'
56
+ console.log(name.givenName); // 'Lan'
57
+
58
+ // Filter by gender and region
59
+ const north = generate({ gender: EGender.Male, region: ERegion.North });
60
+ console.log(north.fullName); // 'Hoàng Văn Minh' (not Huỳnh — North variant)
61
+
62
+ const south = generate({ gender: EGender.Male, region: ERegion.South });
63
+ console.log(south.fullName); // 'Huỳnh Văn Minh' (not Hoàng — South variant)
64
+
65
+ // Modern compound name (tên kép)
66
+ const modern = generateFullName({ era: EEra.Modern, compoundName: true });
67
+ console.log(modern); // 'Lê Thị Bảo Châu'
68
+
69
+ // Filter by meaning
70
+ const nature = generateFullName({ meaningCategory: EMeaningCategory.Nature });
71
+ console.log(nature); // 'Trần Thị Hà' (Hà = river)
72
+
73
+ // Batch generation — uniqueness guaranteed
74
+ const names = generateManyFullNames(5, { gender: EGender.Female });
75
+ // ['Phạm Thị Hoa', 'Võ Ngọc Mai', 'Đặng Thị Linh', ...]
76
+
77
+ // Full result objects in batch
78
+ const results = generateMany(3, { region: ERegion.South });
79
+ results.forEach((r) => console.log(r.fullName, r.era, r.gender));
80
+ ```
81
+
82
+ ## API
83
+
84
+ ### Functions
85
+
86
+ | Function | Returns | Description |
87
+ | ---------------------------------------- | --------------- | ---------------------------------- |
88
+ | `generate(options?)` | `INameResult` | Single name with full metadata |
89
+ | `generateMany(count, options?)` | `INameResult[]` | `count` unique names with metadata |
90
+ | `generateFullName(options?)` | `string` | Single full name string |
91
+ | `generateManyFullNames(count, options?)` | `string[]` | `count` unique full name strings |
92
+
93
+ ### Options
94
+
95
+ All functions accept an optional `TGenerateOptions`:
96
+
97
+ | Option | Type | Default | Description |
98
+ | ----------------- | ------------------ | ------- | --------------------------------- |
99
+ | `gender` | `EGender` | random | `male`, `female`, or `unisex` |
100
+ | `region` | `ERegion` | random | `north`, `central`, or `south` |
101
+ | `era` | `EEra` | random | `traditional` or `modern` |
102
+ | `compoundName` | `boolean` | random | Two-syllable given name (tên kép) |
103
+ | `meaningCategory` | `EMeaningCategory` | any | Filter by semantic category |
104
+ | `withMiddleName` | `boolean` | `true` | Include the middle name (đệm) |
105
+
106
+ ### Result
107
+
108
+ ```typescript
109
+ interface INameResult {
110
+ surname: string;
111
+ middleName: string;
112
+ givenName: string;
113
+ fullName: string; // surname + middleName + givenName
114
+ gender: EGender;
115
+ region: ERegion;
116
+ era: EEra;
117
+ }
118
+ ```
119
+
120
+ ### Enums
121
+
122
+ **`EGender`**
123
+
124
+ | Value | Description |
125
+ | -------- | ------------ |
126
+ | `male` | Male names |
127
+ | `female` | Female names |
128
+ | `unisex` | Unisex names |
129
+
130
+ **`ERegion`**
131
+
132
+ | Value | Description |
133
+ | --------- | --------------------------------- |
134
+ | `north` | Northern Vietnam (e.g. Hoàng, Vũ) |
135
+ | `central` | Central Vietnam |
136
+ | `south` | Southern Vietnam (e.g. Huỳnh, Võ) |
137
+
138
+ **`EEra`**
139
+
140
+ | Value | Description |
141
+ | ------------- | ------------------------------- |
142
+ | `traditional` | Classical Sino-Vietnamese names |
143
+ | `modern` | Contemporary Vietnamese names |
144
+
145
+ **`EMeaningCategory`**
146
+
147
+ | Value | Description |
148
+ | ------------ | ----------------------- |
149
+ | `strength` | Power and fortitude |
150
+ | `virtue` | Moral excellence |
151
+ | `nature` | Natural world |
152
+ | `precious` | Gems and valuables |
153
+ | `beauty` | Aesthetic qualities |
154
+ | `celestial` | Sky, stars, cosmos |
155
+ | `season` | Seasons and weather |
156
+ | `intellect` | Wisdom and knowledge |
157
+ | `prosperity` | Wealth and good fortune |
158
+
159
+ ## Vietnamese Naming
160
+
161
+ Vietnamese names are written **surname → middle name → given name** — the reverse of Western order. In daily life, people are addressed by their given name only; using a full name is formal or distant.
162
+
163
+ **Surname concentration is extreme.** About 40% of Vietnamese people carry the surname Nguyễn — a direct consequence of mass surname assignments during dynastic census policies. The top 14 surnames cover over 90% of the population, which is why the middle name and given name are the true differentiators.
164
+
165
+ **The middle name (đệm) encodes gender.** Văn (文) has historically marked male names; Thị (氏) marks female names. Both are fading in modern usage but remain common. Other middle names like Hữu, Đức, Công (male) or Thùy, Ngọc, Kim (female) add meaning and style.
166
+
167
+ **Region determines which surname form you use.** The same Chinese character is read differently by dialect: Hoàng in the North becomes Huỳnh in the South; Vũ becomes Võ. Names are regionally self-consistent — a southern name will use Huỳnh, Võ, Trương, and so on throughout.
168
+
169
+ **Every given name carries meaning.** Vietnamese parents deliberately choose names for semantic content drawn from Sino-Vietnamese vocabulary: Lan (orchid), Hà (river), Minh (bright/intelligent), Phúc (blessing), Nguyệt (moon). This library's meaning filter maps directly to these categories.
170
+
171
+ **Compound names (tên kép) emerged as a workaround.** With so few surnames in circulation, two-syllable given names like Bảo Châu, Minh Khôi, or Thanh Hà became popular from the late 20th century onward — both for beauty and to reduce ambiguity.
172
+
173
+ **Imperial name taboos left lasting marks.** Under feudal dynasties, using the emperor's personal name (or a near-homophone) was forbidden — a practice called kỵ húy. Banned names became rare and some were respelled entirely, which partly explains unusual character choices still visible in the modern name pool.
174
+
175
+ ## License
176
+
177
+ MIT