zodiac-mapper 0.1.0 → 0.2.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/README.md +31 -13
- package/dist/index.cjs +79 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.mts +8 -1
- package/dist/index.mjs +79 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,21 +1,38 @@
|
|
|
1
|
-
# zodiac-mapper
|
|
1
|
+
# ✨ zodiac-mapper
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/zodiac-mapper)
|
|
4
|
+
[](https://github.com/fixicelo/zodiac-mapper/blob/main/LICENSE)
|
|
5
|
+
|
|
2
6
|
A lightweight, zero-dependency TypeScript NPM package that maps **zodiac sign names in dozens of languages and regional variants** to a standardized `ZodiacSign` enum.
|
|
3
7
|
|
|
4
|
-
Perfect for internationalized astrology apps, horoscope tools, multilingual chatbots, or any project needing robust zodiac name recognition
|
|
8
|
+
🌟 **Perfect for internationalized astrology apps, horoscope tools, multilingual chatbots, or any project needing robust zodiac name recognition.**
|
|
9
|
+
|
|
10
|
+
Supports **50+ locales** 🌍 including English, Chinese, Japanese, German, French, Spanish, Arabic, Persian, Russian, Greek, Hebrew, and more.
|
|
11
|
+
|
|
12
|
+
> ℹ️ **Data note:** the built-in locale alias dataset was generated and curated with AI assistance. While we try to keep it accurate and conventional, it may contain mistakes or regional variations—please open an issue/PR if you spot a problem.
|
|
5
13
|
|
|
6
|
-
|
|
14
|
+
## 📦 Installation
|
|
7
15
|
|
|
8
|
-
|
|
16
|
+
```bash
|
|
17
|
+
# npm
|
|
18
|
+
npm install zodiac-mapper
|
|
9
19
|
|
|
10
|
-
|
|
20
|
+
# pnpm
|
|
21
|
+
pnpm add zodiac-mapper
|
|
11
22
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
# yarn
|
|
24
|
+
yarn add zodiac-mapper
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 🚀 Features
|
|
17
28
|
|
|
18
|
-
|
|
29
|
+
- 🗺️ **Universal Mapping**: Map any language variant → standard zodiac enum
|
|
30
|
+
- 🔍 **Smart Matching**: Case-insensitive, accent-insensitive, and whitespace-tolerant matching
|
|
31
|
+
- 📝 **Text Scanning**: Find the first or all zodiac mentions in a text string
|
|
32
|
+
- ⚡ **Zero Dependencies**: Lightweight and fast
|
|
33
|
+
- 🛡️ **TypeScript**: Fully typed for excellent developer experience
|
|
34
|
+
|
|
35
|
+
## 💻 Usage
|
|
19
36
|
|
|
20
37
|
```ts
|
|
21
38
|
import {
|
|
@@ -62,7 +79,7 @@ getZodiacSignFromDate("2000-03-21") === ZodiacSign.ARIES;
|
|
|
62
79
|
getZodiacSignFromDate("03-21") === ZodiacSign.ARIES;
|
|
63
80
|
```
|
|
64
81
|
|
|
65
|
-
### Locale Filtering (include / exclude)
|
|
82
|
+
### 🌍 Locale Filtering (include / exclude)
|
|
66
83
|
|
|
67
84
|
When scanning free text, limiting languages can reduce false positives.
|
|
68
85
|
|
|
@@ -74,7 +91,8 @@ getZodiacSign("Áries", { includeLocales: ["pt"] });
|
|
|
74
91
|
findFirstZodiacInText("I am Áries", { excludeLocales: ["pt"] });
|
|
75
92
|
```
|
|
76
93
|
|
|
77
|
-
Notes
|
|
94
|
+
### 📝 Notes
|
|
95
|
+
|
|
78
96
|
- Locales are treated as BCP-47 tags; tags like `zh-Hant` will be treated as `zh` for filtering.
|
|
79
97
|
- `symbols` is a special built-in pseudo-locale key (not a BCP-47 tag).
|
|
80
98
|
- The default is permissive (all locales). This is great for astrology-specific text, but can be noisy in general-purpose text.
|
package/dist/index.cjs
CHANGED
|
@@ -574,7 +574,7 @@ const ZODIAC_PER_LOCALE = {
|
|
|
574
574
|
[ZodiacSign.VIRGO]: ["Virgo"],
|
|
575
575
|
[ZodiacSign.LIBRA]: ["Libra"],
|
|
576
576
|
[ZodiacSign.SCORPIO]: ["Scorpio"],
|
|
577
|
-
[ZodiacSign.SAGITTARIUS]: ["
|
|
577
|
+
[ZodiacSign.SAGITTARIUS]: ["Sagittarius"],
|
|
578
578
|
[ZodiacSign.CAPRICORN]: ["Capricorn"],
|
|
579
579
|
[ZodiacSign.AQUARIUS]: ["Aquarius"],
|
|
580
580
|
[ZodiacSign.PISCES]: ["Pisces"]
|
|
@@ -1461,18 +1461,18 @@ const ZODIAC_PER_LOCALE = {
|
|
|
1461
1461
|
[ZodiacSign.PISCES]: ["Mina"]
|
|
1462
1462
|
},
|
|
1463
1463
|
ne: {
|
|
1464
|
-
[ZodiacSign.ARIES]: ["
|
|
1465
|
-
[ZodiacSign.TAURUS]: ["
|
|
1466
|
-
[ZodiacSign.GEMINI]: ["
|
|
1467
|
-
[ZodiacSign.CANCER]: ["
|
|
1468
|
-
[ZodiacSign.LEO]: ["
|
|
1469
|
-
[ZodiacSign.VIRGO]: ["Kanya"],
|
|
1470
|
-
[ZodiacSign.LIBRA]: ["Tula"],
|
|
1471
|
-
[ZodiacSign.SCORPIO]: ["Brischik"],
|
|
1472
|
-
[ZodiacSign.SAGITTARIUS]: ["Dhanu"],
|
|
1473
|
-
[ZodiacSign.CAPRICORN]: ["Makar"],
|
|
1474
|
-
[ZodiacSign.AQUARIUS]: ["
|
|
1475
|
-
[ZodiacSign.PISCES]: ["
|
|
1464
|
+
[ZodiacSign.ARIES]: ["मेष", "Mesh"],
|
|
1465
|
+
[ZodiacSign.TAURUS]: ["वृष", "Brish"],
|
|
1466
|
+
[ZodiacSign.GEMINI]: ["मिथुन", "Mithun"],
|
|
1467
|
+
[ZodiacSign.CANCER]: ["कर्कट", "Karkat"],
|
|
1468
|
+
[ZodiacSign.LEO]: ["सिंह", "Singha"],
|
|
1469
|
+
[ZodiacSign.VIRGO]: ["कन्या", "Kanya"],
|
|
1470
|
+
[ZodiacSign.LIBRA]: ["तुला", "Tula"],
|
|
1471
|
+
[ZodiacSign.SCORPIO]: ["वृश्चिक", "Brischik"],
|
|
1472
|
+
[ZodiacSign.SAGITTARIUS]: ["धनु", "Dhanu"],
|
|
1473
|
+
[ZodiacSign.CAPRICORN]: ["मकर", "Makar"],
|
|
1474
|
+
[ZodiacSign.AQUARIUS]: ["कुम्भ", "Kumbha"],
|
|
1475
|
+
[ZodiacSign.PISCES]: ["मीन", "Meen"]
|
|
1476
1476
|
},
|
|
1477
1477
|
ur: {
|
|
1478
1478
|
[ZodiacSign.ARIES]: ["Hamal", "Mekh"],
|
|
@@ -1956,7 +1956,7 @@ const ZODIAC_PER_LOCALE = {
|
|
|
1956
1956
|
"Mekh"
|
|
1957
1957
|
],
|
|
1958
1958
|
[ZodiacSign.TAURUS]: [
|
|
1959
|
-
"
|
|
1959
|
+
"ਬ੍ਰਿਸ਼ਭ",
|
|
1960
1960
|
"Vrish",
|
|
1961
1961
|
"Vrishabha",
|
|
1962
1962
|
"Brikh"
|
|
@@ -1971,12 +1971,12 @@ const ZODIAC_PER_LOCALE = {
|
|
|
1971
1971
|
[ZodiacSign.VIRGO]: ["ਕੰਨਿਆ", "Kanya"],
|
|
1972
1972
|
[ZodiacSign.LIBRA]: ["ਤੁਲਾ", "Tula"],
|
|
1973
1973
|
[ZodiacSign.SCORPIO]: [
|
|
1974
|
-
"
|
|
1974
|
+
"ਬ੍ਰਿਸ਼ਚਕ",
|
|
1975
1975
|
"Vrishchik",
|
|
1976
1976
|
"Brischak"
|
|
1977
1977
|
],
|
|
1978
1978
|
[ZodiacSign.SAGITTARIUS]: [
|
|
1979
|
-
"
|
|
1979
|
+
"ਧਨੂੰ",
|
|
1980
1980
|
"Dhanu",
|
|
1981
1981
|
"Dhan"
|
|
1982
1982
|
],
|
|
@@ -2401,18 +2401,56 @@ const ZODIAC_PER_LOCALE = {
|
|
|
2401
2401
|
[ZodiacSign.PISCES]: ["ماس", "Masi"]
|
|
2402
2402
|
},
|
|
2403
2403
|
om: {
|
|
2404
|
-
[ZodiacSign.ARIES]: ["
|
|
2405
|
-
[ZodiacSign.TAURUS]: [
|
|
2404
|
+
[ZodiacSign.ARIES]: ["Korbeessa", "Elemoo"],
|
|
2405
|
+
[ZodiacSign.TAURUS]: [
|
|
2406
|
+
"Gafarsa",
|
|
2407
|
+
"Haraashii",
|
|
2408
|
+
"Qotiyyoo",
|
|
2409
|
+
"Korma"
|
|
2410
|
+
],
|
|
2406
2411
|
[ZodiacSign.GEMINI]: ["Lakkuu"],
|
|
2407
|
-
[ZodiacSign.CANCER]: [
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
[ZodiacSign.
|
|
2413
|
-
[ZodiacSign.
|
|
2414
|
-
|
|
2415
|
-
|
|
2412
|
+
[ZodiacSign.CANCER]: [
|
|
2413
|
+
"Qaajibuu",
|
|
2414
|
+
"Qaajibbuu",
|
|
2415
|
+
"Bararii"
|
|
2416
|
+
],
|
|
2417
|
+
[ZodiacSign.LEO]: ["Leencicha", "Leenca"],
|
|
2418
|
+
[ZodiacSign.VIRGO]: [
|
|
2419
|
+
"Duudaa",
|
|
2420
|
+
"Durba",
|
|
2421
|
+
"Dubree"
|
|
2422
|
+
],
|
|
2423
|
+
[ZodiacSign.LIBRA]: [
|
|
2424
|
+
"Maadaltuu",
|
|
2425
|
+
"Madaltoo",
|
|
2426
|
+
"Mizaana"
|
|
2427
|
+
],
|
|
2428
|
+
[ZodiacSign.SCORPIO]: [
|
|
2429
|
+
"Gaawisoo",
|
|
2430
|
+
"Gaawwisoo",
|
|
2431
|
+
"Gaanqabaa"
|
|
2432
|
+
],
|
|
2433
|
+
[ZodiacSign.SAGITTARIUS]: [
|
|
2434
|
+
"Fuggisa xiyyaa",
|
|
2435
|
+
"Xiyyaa",
|
|
2436
|
+
"Xiyya"
|
|
2437
|
+
],
|
|
2438
|
+
[ZodiacSign.CAPRICORN]: [
|
|
2439
|
+
"Reettii",
|
|
2440
|
+
"Qobolee",
|
|
2441
|
+
"Re'ee"
|
|
2442
|
+
],
|
|
2443
|
+
[ZodiacSign.AQUARIUS]: [
|
|
2444
|
+
"Battuu bisaanii",
|
|
2445
|
+
"Tuuja Baaldii",
|
|
2446
|
+
"Kuroo",
|
|
2447
|
+
"Buusaa"
|
|
2448
|
+
],
|
|
2449
|
+
[ZodiacSign.PISCES]: [
|
|
2450
|
+
"Albaadhessa",
|
|
2451
|
+
"Albaadheesaa",
|
|
2452
|
+
"Qurxummii"
|
|
2453
|
+
]
|
|
2416
2454
|
}
|
|
2417
2455
|
};
|
|
2418
2456
|
|
|
@@ -2542,6 +2580,19 @@ function findFirstZodiacInText(text, options) {
|
|
|
2542
2580
|
function findAllZodiacInText(text, options) {
|
|
2543
2581
|
return findZodiacMatchesInText(text, options);
|
|
2544
2582
|
}
|
|
2583
|
+
/**
|
|
2584
|
+
* Returns the list of names/aliases for a given zodiac sign in a specific locale.
|
|
2585
|
+
* @param sign The zodiac sign.
|
|
2586
|
+
* @param locale The locale code (e.g. "en", "zh", "es").
|
|
2587
|
+
* @returns An array of names, or empty array if locale/sign not found.
|
|
2588
|
+
*/
|
|
2589
|
+
function getZodiacNames(sign, locale) {
|
|
2590
|
+
const canonical = canonicalizeLocale(locale);
|
|
2591
|
+
const base = getBaseLanguage(locale);
|
|
2592
|
+
if (ZODIAC_PER_LOCALE[canonical]?.[sign]) return ZODIAC_PER_LOCALE[canonical][sign];
|
|
2593
|
+
if (ZODIAC_PER_LOCALE[base]?.[sign]) return ZODIAC_PER_LOCALE[base][sign];
|
|
2594
|
+
return [];
|
|
2595
|
+
}
|
|
2545
2596
|
function isLatin(str) {
|
|
2546
2597
|
return /^[a-zA-Z\u00C0-\u00FF]+$/.test(str);
|
|
2547
2598
|
}
|
|
@@ -2799,6 +2850,7 @@ exports.findAllZodiacInText = findAllZodiacInText;
|
|
|
2799
2850
|
exports.findFirstZodiacInText = findFirstZodiacInText;
|
|
2800
2851
|
exports.getSupportedLocales = getSupportedLocales;
|
|
2801
2852
|
exports.getZodiacDateRange = getZodiacDateRange;
|
|
2853
|
+
exports.getZodiacNames = getZodiacNames;
|
|
2802
2854
|
exports.getZodiacSign = getZodiacSign;
|
|
2803
2855
|
exports.getZodiacSignFromDate = getZodiacSignFromDate;
|
|
2804
2856
|
exports.normalizeName = normalizeName;
|