zodiac-mapper 0.1.0 → 0.2.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/README.md CHANGED
@@ -1,21 +1,38 @@
1
- # zodiac-mapper
1
+ # zodiac-mapper
2
+
3
+ [![npm version](https://img.shields.io/npm/v/zodiac-mapper.svg)](https://www.npmjs.com/package/zodiac-mapper)
4
+ [![License](https://img.shields.io/npm/l/zodiac-mapper.svg)](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
- Supports **50+ locales** including English, Chinese, Japanese, German, French, Spanish, Arabic, Persian, Russian, Greek, Hebrew, and more.
14
+ ## 📦 Installation
7
15
 
8
- 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.
16
+ ```bash
17
+ # npm
18
+ npm install zodiac-mapper
9
19
 
10
- ## Features
20
+ # pnpm
21
+ pnpm add zodiac-mapper
11
22
 
12
- - Map any language variant → standard zodiac enum
13
- - Case-insensitive, accent-insensitive, and whitespace-tolerant matching
14
- - Find the first or all zodiac mentions in a text string
15
- - No external dependencies
16
- - Fully typed with TypeScript
23
+ # yarn
24
+ yarn add zodiac-mapper
25
+ ```
26
+
27
+ ## 🚀 Features
17
28
 
18
- ## Usage
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
@@ -2542,6 +2542,19 @@ function findFirstZodiacInText(text, options) {
2542
2542
  function findAllZodiacInText(text, options) {
2543
2543
  return findZodiacMatchesInText(text, options);
2544
2544
  }
2545
+ /**
2546
+ * Returns the list of names/aliases for a given zodiac sign in a specific locale.
2547
+ * @param sign The zodiac sign.
2548
+ * @param locale The locale code (e.g. "en", "zh", "es").
2549
+ * @returns An array of names, or empty array if locale/sign not found.
2550
+ */
2551
+ function getZodiacNames(sign, locale) {
2552
+ const canonical = canonicalizeLocale(locale);
2553
+ const base = getBaseLanguage(locale);
2554
+ if (ZODIAC_PER_LOCALE[canonical]?.[sign]) return ZODIAC_PER_LOCALE[canonical][sign];
2555
+ if (ZODIAC_PER_LOCALE[base]?.[sign]) return ZODIAC_PER_LOCALE[base][sign];
2556
+ return [];
2557
+ }
2545
2558
  function isLatin(str) {
2546
2559
  return /^[a-zA-Z\u00C0-\u00FF]+$/.test(str);
2547
2560
  }
@@ -2799,6 +2812,7 @@ exports.findAllZodiacInText = findAllZodiacInText;
2799
2812
  exports.findFirstZodiacInText = findFirstZodiacInText;
2800
2813
  exports.getSupportedLocales = getSupportedLocales;
2801
2814
  exports.getZodiacDateRange = getZodiacDateRange;
2815
+ exports.getZodiacNames = getZodiacNames;
2802
2816
  exports.getZodiacSign = getZodiacSign;
2803
2817
  exports.getZodiacSignFromDate = getZodiacSignFromDate;
2804
2818
  exports.normalizeName = normalizeName;