@pie-element/shared-controller-utils 0.1.5-next.20261026200905 → 0.1.5-next.20261109072207
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 +5 -1
- package/dist/index.js +1 -1
- package/dist/response-normalizer.d.ts +8 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,7 +17,11 @@ This package is part of the PIE workspace and should be installed via workspace
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
getShuffledChoices,
|
|
22
|
+
lockChoices,
|
|
23
|
+
partialScoring,
|
|
24
|
+
} from '@pie-element/shared-controller-utils';
|
|
21
25
|
```
|
|
22
26
|
|
|
23
27
|
### Response normalization
|
package/dist/index.js
CHANGED
|
@@ -88,7 +88,7 @@ var l = /[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069\u0640]/g, u = /[\uFB50-\u
|
|
|
88
88
|
}
|
|
89
89
|
}, E = (e, t = {}) => {
|
|
90
90
|
let n = S(t.language), r = (t.ignoreCase ? T(e, t.language) : e).replace(l, "").replace(u, (e) => e.normalize("NFKC")).normalize("NFC");
|
|
91
|
-
return r = y(r).replace(p, n.decimal).replace(m, n.group), t.foldLetterVariants && (r = r.replace(g, "").replace(h, "ا").replace(/\u0629/g, "ه").replace(/\u0649/g, "ي")), r;
|
|
91
|
+
return r = y(r).replace(p, n.decimal).replace(m, n.group), t.foldLetterVariants && (r = r.replace(g, "").replace(h, "ا").replace(/\u0629/g, "ه").replace(/\u0649/g, "ي")), t.ignoreAccents && (r = r.normalize("NFD").replace(/[\u0300-\u036F]/g, "").normalize("NFC")), t.collapseWhitespace && (r = r.replace(/\s+/g, " ").trim()), t.ignoreSlashSpacing && (r = r.replace(/\s*\/\s*/g, "/")), r;
|
|
92
92
|
};
|
|
93
93
|
//#endregion
|
|
94
94
|
export { C as contentLanguage, T as foldCase, y as foldDigits, a as getShuffledChoices, o as lockChoices, E as normalizeResponse, s as partialScoring };
|
|
@@ -24,6 +24,12 @@ export interface NormalizeOptions {
|
|
|
24
24
|
* because it changes what counts as correct spelling.
|
|
25
25
|
*/
|
|
26
26
|
foldLetterVariants?: boolean;
|
|
27
|
+
/** Collapse each run of whitespace, non-breaking spaces included, to one space and trim the ends. */
|
|
28
|
+
collapseWhitespace?: boolean;
|
|
29
|
+
/** Remove whitespace around `/`, so `3 / 4` compares equal to `3/4`. */
|
|
30
|
+
ignoreSlashSpacing?: boolean;
|
|
31
|
+
/** Remove the combining diacritics U+0300–U+036F, so `é` compares equal to `e`. */
|
|
32
|
+
ignoreAccents?: boolean;
|
|
27
33
|
}
|
|
28
34
|
/** Every Unicode decimal digit (`\p{Nd}`) replaced by its ASCII digit. */
|
|
29
35
|
export declare const foldDigits: (value: string) => string;
|
|
@@ -43,6 +49,7 @@ export declare const foldCase: (value: string, language?: string) => string;
|
|
|
43
49
|
* when the options ask for it; bidi controls and tatweel removed; Arabic
|
|
44
50
|
* presentation forms folded to base letters; NFC; every decimal digit folded
|
|
45
51
|
* to 0–9; `٫` and `٬` replaced by the content language's decimal and group
|
|
46
|
-
* marks. Arabic letter variants
|
|
52
|
+
* marks. Arabic letter variants, accents, whitespace runs and the spacing
|
|
53
|
+
* around `/` fold only when the options ask for it.
|
|
47
54
|
*/
|
|
48
55
|
export declare const normalizeResponse: (value: string, options?: NormalizeOptions) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/shared-controller-utils",
|
|
3
|
-
"version": "0.1.5-next.
|
|
3
|
+
"version": "0.1.5-next.20261109072207",
|
|
4
4
|
"description": "Controller utility functions for PIE elements",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"clean": "rm -rf dist"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@pie-element/shared-types": "0.2.4-next.
|
|
24
|
+
"@pie-element/shared-types": "0.2.4-next.20261026212738"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|