@thi.ng/strings 3.0.3 → 3.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/CHANGELOG.md +11 -0
- package/README.md +1 -1
- package/entities.d.ts +7 -0
- package/entities.js +24 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +10 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/strings@3.0.3...@thi.ng/strings@3.1.0) (2021-10-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **strings:** migrate/add entities, regexes, fns ([57c246d](https://github.com/thi-ng/umbrella/commit/57c246df06279a2e70cfb28ce34ff8d9666b0199))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [3.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/strings@3.0.2...@thi.ng/strings@3.0.3) (2021-10-15)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @thi.ng/strings
|
package/README.md
CHANGED
package/entities.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const ENTITIES: Record<string, string>;
|
|
2
|
+
export declare const RE_ENTITIES: RegExp;
|
|
3
|
+
export declare const ENTITIES_REV: Record<string, string>;
|
|
4
|
+
export declare const RE_ENTITIES_REV: RegExp;
|
|
5
|
+
export declare const escapeEntities: (src: string) => string;
|
|
6
|
+
export declare const unescapeEntities: (src: string) => string;
|
|
7
|
+
//# sourceMappingURL=entities.d.ts.map
|
package/entities.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const ENTITIES = {
|
|
2
|
+
"&": "&",
|
|
3
|
+
"<": "<",
|
|
4
|
+
">": ">",
|
|
5
|
+
'"': """,
|
|
6
|
+
"'": "'",
|
|
7
|
+
"—": "—",
|
|
8
|
+
"–": "–",
|
|
9
|
+
"…": "…",
|
|
10
|
+
"¢": "¢",
|
|
11
|
+
"€": "€",
|
|
12
|
+
"£": "£",
|
|
13
|
+
"§": "§",
|
|
14
|
+
"©": "©",
|
|
15
|
+
"®": "®",
|
|
16
|
+
"™": "™",
|
|
17
|
+
"\xa0": " ",
|
|
18
|
+
};
|
|
19
|
+
export const RE_ENTITIES = new RegExp(`[${Object.keys(ENTITIES).join("")}]`, "g");
|
|
20
|
+
export const ENTITIES_REV = Object.entries(ENTITIES).reduce((acc, [k, v]) => ((acc[v] = k), acc), {});
|
|
21
|
+
export const RE_ENTITIES_REV = new RegExp(`(${Object.keys(ENTITIES_REV).join("|")})`, "g");
|
|
22
|
+
const $esc = (re, index) => (src) => src.replace(re, (x) => index[x]);
|
|
23
|
+
export const escapeEntities = $esc(RE_ENTITIES, ENTITIES);
|
|
24
|
+
export const unescapeEntities = $esc(RE_ENTITIES_REV, ENTITIES_REV);
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/strings",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Various string formatting & utility functions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.0.
|
|
38
|
-
"@thi.ng/errors": "^2.0.
|
|
39
|
-
"@thi.ng/hex": "^2.0.
|
|
40
|
-
"@thi.ng/memoize": "^3.0.
|
|
37
|
+
"@thi.ng/api": "^8.0.4",
|
|
38
|
+
"@thi.ng/errors": "^2.0.4",
|
|
39
|
+
"@thi.ng/hex": "^2.0.4",
|
|
40
|
+
"@thi.ng/memoize": "^3.0.4"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@thi.ng/testament": "^0.1.
|
|
43
|
+
"@thi.ng/testament": "^0.1.4"
|
|
44
44
|
},
|
|
45
45
|
"keywords": [
|
|
46
46
|
"ansi",
|
|
@@ -95,6 +95,9 @@
|
|
|
95
95
|
"./cursor": {
|
|
96
96
|
"import": "./cursor.js"
|
|
97
97
|
},
|
|
98
|
+
"./entities": {
|
|
99
|
+
"import": "./entities.js"
|
|
100
|
+
},
|
|
98
101
|
"./escape": {
|
|
99
102
|
"import": "./escape.js"
|
|
100
103
|
},
|
|
@@ -189,5 +192,5 @@
|
|
|
189
192
|
"thi.ng": {
|
|
190
193
|
"year": 2015
|
|
191
194
|
},
|
|
192
|
-
"gitHead": "
|
|
195
|
+
"gitHead": "9ff00a103f76cc4917ef3f244132e218f2300a05"
|
|
193
196
|
}
|