@robert-brightline/names 0.0.1
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 +34 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/names.d.ts +10 -0
- package/dist/lib/names.d.ts.map +1 -0
- package/dist/lib/names.js +14 -0
- package/dist/lib/names.js.map +1 -0
- package/dist/lib/normalize-name.d.ts +2 -0
- package/dist/lib/normalize-name.d.ts.map +1 -0
- package/dist/lib/normalize-name.js +5 -0
- package/dist/lib/normalize-name.js.map +1 -0
- package/dist/lib/pluralize.d.ts +2 -0
- package/dist/lib/pluralize.d.ts.map +1 -0
- package/dist/lib/pluralize.js +41 -0
- package/dist/lib/pluralize.js.map +1 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
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,34 @@
|
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
<p align="center">
|
|
7
|
+
<img src="./assets/favicon.png" alt="Logo" width="200" height="200" style="border-radius: 100%"/>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
## @robert-brightline/names
|
|
11
|
+
|
|
12
|
+
Utility function to create name variants
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @robert-brightline/names
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 💖 Support My Work
|
|
21
|
+
|
|
22
|
+
If you find my open-source contributions or the **@robert-brightline/names** project helpful, consider supporting my work. Your sponsorship helps me maintain these projects and explore new enterprise patterns.
|
|
23
|
+
|
|
24
|
+
[]([object Object])
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 🤝 Connect with Me
|
|
29
|
+
|
|
30
|
+
<p align="left">
|
|
31
|
+
<a href="mailto:robert.brightline+names@gmail.com?subject=@robert-brightline/names">
|
|
32
|
+
<img src="https://img.shields.io/badge/Email-D14836?style=for-the-badge&logo=gmail&logoColor=white" />
|
|
33
|
+
</a>
|
|
34
|
+
</p>
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @index(['./**/*.ts', '!./**/*.{test,spec}.ts'], f => `export * from '${f.path}.js'`)\nexport * from './lib/names.js';\nexport * from './lib/normalize-name.js';\nexport * from './lib/pluralize.js';\n\n"],"names":[],"rangeMappings":";;;","mappings":"AAAA,uFAAuF;AACvF,cAAc,iBAAiB;AAC/B,cAAc,0BAA0B;AACxC,cAAc,qBAAqB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../../src/lib/names.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,KAAK,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAczC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { normalizeName } from './normalize-name.js';
|
|
2
|
+
export function names(name) {
|
|
3
|
+
const n = normalizeName(name);
|
|
4
|
+
return {
|
|
5
|
+
camel: n.replace(/-([a-z])/g, (_, letter)=>letter.toUpperCase()),
|
|
6
|
+
pascal: n.replace(/-([a-z])/g, (_, letter)=>letter.toUpperCase()).replace(/^[a-z]/, (letter)=>letter.toUpperCase()),
|
|
7
|
+
snake: n.replace(/-/g, '_'),
|
|
8
|
+
kebab: n,
|
|
9
|
+
constant: n.replace(/-/g, '_').toUpperCase(),
|
|
10
|
+
title: n.replace(/-([a-z])/g, (_, letter)=>' ' + letter.toUpperCase()).replace(/^[a-z]/, (letter)=>letter.toUpperCase())
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/names.ts"],"sourcesContent":["import { normalizeName } from './normalize-name.js';\n\nexport type Names = {\n camel: string;\n pascal: string;\n snake: string;\n kebab: string;\n constant: string;\n title: string;\n};\n\nexport function names(name: string): Names {\n const n = normalizeName(name);\n return {\n camel: n.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()),\n pascal: n\n .replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())\n .replace(/^[a-z]/, (letter) => letter.toUpperCase()),\n snake: n.replace(/-/g, '_'),\n kebab: n,\n constant: n.replace(/-/g, '_').toUpperCase(),\n title: n\n .replace(/-([a-z])/g, (_, letter) => ' ' + letter.toUpperCase())\n .replace(/^[a-z]/, (letter) => letter.toUpperCase()),\n };\n}\n"],"names":["normalizeName","names","name","n","camel","replace","_","letter","toUpperCase","pascal","snake","kebab","constant","title"],"rangeMappings":";;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAAQ,sBAAsB;AAWpD,OAAO,SAASC,MAAMC,IAAY;IAChC,MAAMC,IAAIH,cAAcE;IACxB,OAAO;QACLE,OAAOD,EAAEE,OAAO,CAAC,aAAa,CAACC,GAAGC,SAAWA,OAAOC,WAAW;QAC/DC,QAAQN,EACLE,OAAO,CAAC,aAAa,CAACC,GAAGC,SAAWA,OAAOC,WAAW,IACtDH,OAAO,CAAC,UAAU,CAACE,SAAWA,OAAOC,WAAW;QACnDE,OAAOP,EAAEE,OAAO,CAAC,MAAM;QACvBM,OAAOR;QACPS,UAAUT,EAAEE,OAAO,CAAC,MAAM,KAAKG,WAAW;QAC1CK,OAAOV,EACJE,OAAO,CAAC,aAAa,CAACC,GAAGC,SAAW,MAAMA,OAAOC,WAAW,IAC5DH,OAAO,CAAC,UAAU,CAACE,SAAWA,OAAOC,WAAW;IACrD;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-name.d.ts","sourceRoot":"","sources":["../../src/lib/normalize-name.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/normalize-name.ts"],"sourcesContent":["export function normalizeName(anyCase: string): string {\n return anyCase\n .trim()\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/[\\s_.-]{1,}/g, '-')\n .toLowerCase();\n}\n"],"names":["normalizeName","anyCase","trim","replace","toLowerCase"],"rangeMappings":";;","mappings":"AAAA,OAAO,SAASA,cAAcC,OAAe;IAC3C,OAAOA,QACJC,IAAI,GACJC,OAAO,CAAC,sBAAsB,SAC9BA,OAAO,CAAC,gBAAgB,KACxBC,WAAW;AAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluralize.d.ts","sourceRoot":"","sources":["../../src/lib/pluralize.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA6D9C"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export function pluralize(name) {
|
|
2
|
+
const irregulars = {
|
|
3
|
+
child: 'children',
|
|
4
|
+
person: 'people',
|
|
5
|
+
man: 'men',
|
|
6
|
+
woman: 'women',
|
|
7
|
+
tooth: 'teeth',
|
|
8
|
+
foot: 'feet',
|
|
9
|
+
mouse: 'mice',
|
|
10
|
+
goose: 'geese',
|
|
11
|
+
ox: 'oxen',
|
|
12
|
+
cactus: 'cacti',
|
|
13
|
+
focus: 'foci',
|
|
14
|
+
fungus: 'fungi',
|
|
15
|
+
nucleus: 'nuclei',
|
|
16
|
+
syllabus: 'syllabi',
|
|
17
|
+
analysis: 'analyses',
|
|
18
|
+
diagnosis: 'diagnoses',
|
|
19
|
+
oasis: 'oases',
|
|
20
|
+
thesis: 'theses',
|
|
21
|
+
crisis: 'crises',
|
|
22
|
+
phenomenon: 'phenomena',
|
|
23
|
+
criterion: 'criteria',
|
|
24
|
+
datum: 'data'
|
|
25
|
+
};
|
|
26
|
+
if (irregulars[name.toLowerCase()]) {
|
|
27
|
+
return irregulars[name.toLowerCase()];
|
|
28
|
+
}
|
|
29
|
+
if (name.endsWith('o') && !name.endsWith('ao') && !name.endsWith('eo') && !name.endsWith('io') && !name.endsWith('oo') && !name.endsWith('uo')) {
|
|
30
|
+
return name + 'es';
|
|
31
|
+
}
|
|
32
|
+
if (name.endsWith('y') && !name.endsWith('ay') && !name.endsWith('ey') && !name.endsWith('iy') && !name.endsWith('oy') && !name.endsWith('uy')) {
|
|
33
|
+
return name.slice(0, -1) + 'ies';
|
|
34
|
+
} else if (name.endsWith('s') || name.endsWith('x') || name.endsWith('z') || name.endsWith('ch') || name.endsWith('sh')) {
|
|
35
|
+
return name + 'es';
|
|
36
|
+
} else {
|
|
37
|
+
return name + 's';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=pluralize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/pluralize.ts"],"sourcesContent":["export function pluralize(name: string): string {\n const irregulars: Record<string, string> = {\n child: 'children',\n person: 'people',\n man: 'men',\n woman: 'women',\n tooth: 'teeth',\n foot: 'feet',\n mouse: 'mice',\n goose: 'geese',\n ox: 'oxen',\n cactus: 'cacti',\n focus: 'foci',\n fungus: 'fungi',\n nucleus: 'nuclei',\n syllabus: 'syllabi',\n analysis: 'analyses',\n diagnosis: 'diagnoses',\n oasis: 'oases',\n thesis: 'theses',\n crisis: 'crises',\n phenomenon: 'phenomena',\n criterion: 'criteria',\n datum: 'data',\n };\n\n if (irregulars[name.toLowerCase()]) {\n return irregulars[name.toLowerCase()];\n }\n\n if (\n name.endsWith('o') &&\n !name.endsWith('ao') &&\n !name.endsWith('eo') &&\n !name.endsWith('io') &&\n !name.endsWith('oo') &&\n !name.endsWith('uo')\n ) {\n return name + 'es';\n }\n\n if (\n name.endsWith('y') &&\n !name.endsWith('ay') &&\n !name.endsWith('ey') &&\n !name.endsWith('iy') &&\n !name.endsWith('oy') &&\n !name.endsWith('uy')\n ) {\n return name.slice(0, -1) + 'ies';\n } else if (\n name.endsWith('s') ||\n name.endsWith('x') ||\n name.endsWith('z') ||\n name.endsWith('ch') ||\n name.endsWith('sh')\n ) {\n return name + 'es';\n } else {\n return name + 's';\n }\n}\n"],"names":["pluralize","name","irregulars","child","person","man","woman","tooth","foot","mouse","goose","ox","cactus","focus","fungus","nucleus","syllabus","analysis","diagnosis","oasis","thesis","crisis","phenomenon","criterion","datum","toLowerCase","endsWith","slice"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAO,SAASA,UAAUC,IAAY;IACpC,MAAMC,aAAqC;QACzCC,OAAO;QACPC,QAAQ;QACRC,KAAK;QACLC,OAAO;QACPC,OAAO;QACPC,MAAM;QACNC,OAAO;QACPC,OAAO;QACPC,IAAI;QACJC,QAAQ;QACRC,OAAO;QACPC,QAAQ;QACRC,SAAS;QACTC,UAAU;QACVC,UAAU;QACVC,WAAW;QACXC,OAAO;QACPC,QAAQ;QACRC,QAAQ;QACRC,YAAY;QACZC,WAAW;QACXC,OAAO;IACT;IAEA,IAAItB,UAAU,CAACD,KAAKwB,WAAW,GAAG,EAAE;QAClC,OAAOvB,UAAU,CAACD,KAAKwB,WAAW,GAAG;IACvC;IAEA,IACExB,KAAKyB,QAAQ,CAAC,QACd,CAACzB,KAAKyB,QAAQ,CAAC,SACf,CAACzB,KAAKyB,QAAQ,CAAC,SACf,CAACzB,KAAKyB,QAAQ,CAAC,SACf,CAACzB,KAAKyB,QAAQ,CAAC,SACf,CAACzB,KAAKyB,QAAQ,CAAC,OACf;QACA,OAAOzB,OAAO;IAChB;IAEA,IACEA,KAAKyB,QAAQ,CAAC,QACd,CAACzB,KAAKyB,QAAQ,CAAC,SACf,CAACzB,KAAKyB,QAAQ,CAAC,SACf,CAACzB,KAAKyB,QAAQ,CAAC,SACf,CAACzB,KAAKyB,QAAQ,CAAC,SACf,CAACzB,KAAKyB,QAAQ,CAAC,OACf;QACA,OAAOzB,KAAK0B,KAAK,CAAC,GAAG,CAAC,KAAK;IAC7B,OAAO,IACL1B,KAAKyB,QAAQ,CAAC,QACdzB,KAAKyB,QAAQ,CAAC,QACdzB,KAAKyB,QAAQ,CAAC,QACdzB,KAAKyB,QAAQ,CAAC,SACdzB,KAAKyB,QAAQ,CAAC,OACd;QACA,OAAOzB,OAAO;IAChB,OAAO;QACL,OAAOA,OAAO;IAChB;AACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@robert-brightline/names",
|
|
3
|
+
"description": "Utility function to create name variants.",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "robert-brightline",
|
|
7
|
+
"email": "robert.brightline+names@gmail.com"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/robert-brightline/robert-brightline.git/libs/names",
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"tag": "latest"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"names"
|
|
16
|
+
],
|
|
17
|
+
"funding": [
|
|
18
|
+
{
|
|
19
|
+
"type": "cashapp",
|
|
20
|
+
"url": "https://cash.app/$puqlib"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"module": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
".": {
|
|
30
|
+
"@robert-brightline/source": "./src/index.ts",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"assets",
|
|
39
|
+
"!**/*.tsbuildinfo"
|
|
40
|
+
],
|
|
41
|
+
"nx": {
|
|
42
|
+
"sourceRoot": "libs/names/src",
|
|
43
|
+
"targets": {
|
|
44
|
+
"build": {
|
|
45
|
+
"executor": "@nx/js:swc",
|
|
46
|
+
"outputs": [
|
|
47
|
+
"{options.outputPath}"
|
|
48
|
+
],
|
|
49
|
+
"options": {
|
|
50
|
+
"outputPath": "libs/names/dist",
|
|
51
|
+
"main": "libs/names/src/index.ts",
|
|
52
|
+
"tsConfig": "libs/names/tsconfig.lib.json",
|
|
53
|
+
"skipTypeCheck": false,
|
|
54
|
+
"stripLeadingPaths": true
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@swc/helpers": "~0.5.11"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"vitest": "^4.0.8"
|
|
64
|
+
}
|
|
65
|
+
}
|