@stll/text-normalize 0.1.1 → 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/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/unicode.d.ts +12 -0
- package/dist/unicode.js +23 -0
- package/dist/unicode.js.map +1 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -10,3 +10,5 @@ export type { FoldedSearchText, SearchMatchRange } from "./search-match.js";
|
|
|
10
10
|
export { collapseSpacedLetters, spacedLetterRunRegex, } from "./spaced-letters.js";
|
|
11
11
|
export { slugify } from "./slug.js";
|
|
12
12
|
export type { SlugCharset, SlugifyOptions, SlugSeparator } from "./slug.js";
|
|
13
|
+
export { normalizeUnicode, stripUnicodeMarks, UNICODE_NORMALIZATION_FORMS, } from "./unicode.js";
|
|
14
|
+
export type { UnicodeMarkClass, UnicodeNormalizationForm } from "./unicode.js";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// parser-output-unchanged: Unicode owner migration retains native normalization forms, mark classes and operation order; no folding is added.
|
|
1
2
|
export { applyArabicFolds, applyArabicFoldsWithOffsets, ARABIC_DIGIT_FOLDS, ARABIC_LETTER_FOLDS, ARABIC_REMOVED, } from "./arabic.js";
|
|
2
3
|
export { foldToAscii } from "./ascii-fold.js";
|
|
3
4
|
export { ASCII_FOLD_TABLE } from "./ascii-fold-table.js";
|
|
@@ -7,4 +8,5 @@ export { arabicNormalize } from "./normalize.js";
|
|
|
7
8
|
export { findSearchMatchRanges, foldSearchMatchText, foldSearchMatchTextWithOffsets, } from "./search-match.js";
|
|
8
9
|
export { collapseSpacedLetters, spacedLetterRunRegex, } from "./spaced-letters.js";
|
|
9
10
|
export { slugify } from "./slug.js";
|
|
11
|
+
export { normalizeUnicode, stripUnicodeMarks, UNICODE_NORMALIZATION_FORMS, } from "./unicode.js";
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,8BAA8B,GAC/B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,8BAA8B,GAC/B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,2BAA2B,GAC5B,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const UNICODE_NORMALIZATION_FORMS: readonly ["NFC", "NFD", "NFKC", "NFKD"];
|
|
2
|
+
export type UnicodeNormalizationForm = (typeof UNICODE_NORMALIZATION_FORMS)[number];
|
|
3
|
+
export type UnicodeMarkClass = "combining" | "diacritic" | "basic-combining";
|
|
4
|
+
type StripUnicodeMarksOptions = {
|
|
5
|
+
form: UnicodeNormalizationForm;
|
|
6
|
+
markClass: UnicodeMarkClass;
|
|
7
|
+
};
|
|
8
|
+
/** Applies one explicit Unicode normalization form without additional folding. */
|
|
9
|
+
export declare const normalizeUnicode: (text: string, form: UnicodeNormalizationForm) => string;
|
|
10
|
+
/** Normalizes text, then removes the caller's exact historical mark class. */
|
|
11
|
+
export declare const stripUnicodeMarks: (text: string, { form, markClass }: StripUnicodeMarksOptions) => string;
|
|
12
|
+
export {};
|
package/dist/unicode.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// parser-output-unchanged: Unicode owner migration retains native normalization forms, mark classes and operation order; no folding is added.
|
|
2
|
+
export const UNICODE_NORMALIZATION_FORMS = [
|
|
3
|
+
"NFC",
|
|
4
|
+
"NFD",
|
|
5
|
+
"NFKC",
|
|
6
|
+
"NFKD",
|
|
7
|
+
];
|
|
8
|
+
const COMBINING_MARKS = /\p{M}/gu;
|
|
9
|
+
const DIACRITICS = /\p{Diacritic}/gu;
|
|
10
|
+
const BASIC_COMBINING_MARKS = /[\u0300-\u036f]/gu;
|
|
11
|
+
const MARK_PATTERNS = {
|
|
12
|
+
combining: COMBINING_MARKS,
|
|
13
|
+
diacritic: DIACRITICS,
|
|
14
|
+
"basic-combining": BASIC_COMBINING_MARKS,
|
|
15
|
+
};
|
|
16
|
+
/** Applies one explicit Unicode normalization form without additional folding. */
|
|
17
|
+
export const normalizeUnicode = (text, form) => text.normalize(form);
|
|
18
|
+
/** Normalizes text, then removes the caller's exact historical mark class. */
|
|
19
|
+
export const stripUnicodeMarks = (text, { form, markClass }) => {
|
|
20
|
+
const normalized = normalizeUnicode(text, form);
|
|
21
|
+
return normalized.replaceAll(MARK_PATTERNS[markClass], "");
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=unicode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unicode.js","sourceRoot":"","sources":["../src/unicode.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;CACE,CAAC;AAYX,MAAM,eAAe,GAAG,SAAS,CAAC;AAClC,MAAM,UAAU,GAAG,iBAAiB,CAAC;AACrC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAClD,MAAM,aAAa,GAAG;IACpB,SAAS,EAAE,eAAe;IAC1B,SAAS,EAAE,UAAU;IACrB,iBAAiB,EAAE,qBAAqB;CACW,CAAC;AAEtD,kFAAkF;AAClF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAY,EACZ,IAA8B,EACtB,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAAY,EACZ,EAAE,IAAI,EAAE,SAAS,EAA4B,EACrC,EAAE;IACV,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAChD,OAAO,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/text-normalize",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Search match-key text normalization — Arabic orthographic variant folding (alef/hamza/teh-marbuta/yeh, tashkeel, tatweel, digits) with per-language fold tables",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arabic",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"build": "rm -rf dist && bun ../../packages/scripts/src/tsc-native.ts -p tsconfig.build.json",
|
|
43
43
|
"pack:dry-run": "bun pm pack --dry-run",
|
|
44
44
|
"test": "bun test src",
|
|
45
|
-
"test:property": "bun test --preload @stll/property-testing/preload $(grep -
|
|
46
|
-
"typecheck": "bun
|
|
45
|
+
"test:property": "bun test --preload @stll/property-testing/preload $(grep -rlE 'fc\\.assert|assertProperty' src --include='*.test.ts')",
|
|
46
|
+
"typecheck": "bun check --no-pretty --all --project=tsconfig.json",
|
|
47
47
|
"lint": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --report-unused-disable-directives-severity=error --type-aware --type-check packages/text-normalize",
|
|
48
48
|
"lint:fix": "cd ../.. && bun --bun oxlint -c oxlint.config.ts --type-aware --fix packages/text-normalize",
|
|
49
49
|
"format": "bun ../../scripts/run-oxfmt.ts .",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@stll/property-testing": "0.0.0",
|
|
54
54
|
"@stll/typescript-config": "0.0.0",
|
|
55
|
-
"bun-types": "1.4.
|
|
56
|
-
"fast-check": "^4.10.
|
|
55
|
+
"bun-types": "1.4.3",
|
|
56
|
+
"fast-check": "^4.10.2"
|
|
57
57
|
}
|
|
58
58
|
}
|