zodiac-mapper 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) 2025 fixicelo
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,80 @@
1
+ # zodiac-mapper
2
+ 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
+
4
+ Perfect for internationalized astrology apps, horoscope tools, multilingual chatbots, or any project needing robust zodiac name recognition.
5
+
6
+ Supports **50+ locales** including English, Chinese, Japanese, German, French, Spanish, Arabic, Persian, Russian, Greek, Hebrew, and more.
7
+
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.
9
+
10
+ ## Features
11
+
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
17
+
18
+ ## Usage
19
+
20
+ ```ts
21
+ import {
22
+ createZodiacMatcher,
23
+ findAllZodiacInText,
24
+ findFirstZodiacInText,
25
+ getZodiacDateRange,
26
+ getZodiacSign,
27
+ getZodiacSignFromDate,
28
+ getSupportedLocales,
29
+ ZodiacSign,
30
+ } from "zodiac-mapper";
31
+
32
+ // 1) Map a single name to a ZodiacSign (or null if unknown)
33
+ getZodiacSign("Taureau") === ZodiacSign.TAURUS;
34
+ getZodiacSign("Unknown") === null;
35
+
36
+ // 2) Scan text: find the first match (or null if none)
37
+ const first = findFirstZodiacInText("My sign is Löwe");
38
+ // first => { sign: ZodiacSign.LEO, match: "Löwe", index: 11 }
39
+
40
+ // 3) Scan text: find all matches (empty array if none)
41
+ const all = findAllZodiacInText("Aries, Taurus, and Löwe");
42
+ // all => [
43
+ // { sign: ZodiacSign.ARIES, match: "Aries", index: 0 },
44
+ // { sign: ZodiacSign.TAURUS, match: "Taurus", index: 7 },
45
+ // { sign: ZodiacSign.LEO, match: "Löwe", index: 19 },
46
+ // ]
47
+
48
+ // Inspect available locale data keys
49
+ const locales = getSupportedLocales();
50
+ // locales => ["en", "fr", "de", ...]
51
+
52
+ // 4) Reuse a matcher with fixed options (saves repeated option passing)
53
+ const ptOnly = createZodiacMatcher({ includeLocales: ["pt"] });
54
+ ptOnly.getZodiacSign("Áries") === ZodiacSign.ARIES;
55
+
56
+ // 5) Date helpers (tropical / Western zodiac)
57
+ getZodiacDateRange(ZodiacSign.ARIES);
58
+ // => { start: { month: 3, day: 21 }, end: { month: 4, day: 19 }, crossesYear: false }
59
+
60
+ getZodiacSignFromDate({ month: 3, day: 21 }) === ZodiacSign.ARIES;
61
+ getZodiacSignFromDate("2000-03-21") === ZodiacSign.ARIES;
62
+ getZodiacSignFromDate("03-21") === ZodiacSign.ARIES;
63
+ ```
64
+
65
+ ### Locale Filtering (include / exclude)
66
+
67
+ When scanning free text, limiting languages can reduce false positives.
68
+
69
+ ```ts
70
+ // Only match Portuguese
71
+ getZodiacSign("Áries", { includeLocales: ["pt"] });
72
+
73
+ // Scan text but exclude Portuguese
74
+ findFirstZodiacInText("I am Áries", { excludeLocales: ["pt"] });
75
+ ```
76
+
77
+ Notes:
78
+ - Locales are treated as BCP-47 tags; tags like `zh-Hant` will be treated as `zh` for filtering.
79
+ - `symbols` is a special built-in pseudo-locale key (not a BCP-47 tag).
80
+ - The default is permissive (all locales). This is great for astrology-specific text, but can be noisy in general-purpose text.