@thi.ng/strings 3.4.13 → 3.5.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 -1
- package/README.md +9 -8
- package/entities.d.ts +1 -0
- package/entities.js +29 -1
- package/package.json +2 -2
- package/units.d.ts +1 -0
- package/units.js +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-
|
|
3
|
+
- **Last updated**: 2023-09-15T12:33:37Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,16 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [3.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.5.0) (2023-09-15)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add more HTML entities ([9fa5d91](https://github.com/thi-ng/umbrella/commit/9fa5d91))
|
|
17
|
+
- add support for numeric HTML entities ([8d942ba](https://github.com/thi-ng/umbrella/commit/8d942ba))
|
|
18
|
+
- add `RE_ENTITIES_NUM`
|
|
19
|
+
- update unescapeEntities() to also support numeric entities
|
|
20
|
+
- add unitless() formatter ([d5025ce](https://github.com/thi-ng/umbrella/commit/d5025ce))
|
|
21
|
+
|
|
12
22
|
### [3.4.12](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.4.12) (2023-08-22)
|
|
13
23
|
|
|
14
24
|
#### 🩹 Bug fixes
|
package/README.md
CHANGED
|
@@ -141,7 +141,7 @@ For Node.js REPL:
|
|
|
141
141
|
const strings = await import("@thi.ng/strings");
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 4.
|
|
144
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 4.84 KB
|
|
145
145
|
|
|
146
146
|
## Dependencies
|
|
147
147
|
|
|
@@ -158,13 +158,14 @@ directory are using this package.
|
|
|
158
158
|
|
|
159
159
|
A selection:
|
|
160
160
|
|
|
161
|
-
| Screenshot | Description
|
|
162
|
-
|
|
163
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/big-font.png" width="240"/> | Large ASCII font text generator using @thi.ng/rdom
|
|
164
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/crypto-chart.png" width="240"/> | Basic crypto-currency candle chart with multiple moving averages plots
|
|
165
|
-
| | Basic SPA example with atom-based UI router
|
|
166
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
167
|
-
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/
|
|
161
|
+
| Screenshot | Description | Live demo | Source |
|
|
162
|
+
|:---------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------|:----------------------------------------------------------|:---------------------------------------------------------------------------------------|
|
|
163
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/big-font.png" width="240"/> | Large ASCII font text generator using @thi.ng/rdom | [Demo](https://demo.thi.ng/umbrella/big-font/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/big-font) |
|
|
164
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/crypto-chart.png" width="240"/> | Basic crypto-currency candle chart with multiple moving averages plots | [Demo](https://demo.thi.ng/umbrella/crypto-chart/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/crypto-chart) |
|
|
165
|
+
| | Basic SPA example with atom-based UI router | [Demo](https://demo.thi.ng/umbrella/login-form/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/login-form) |
|
|
166
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/mastodon-feed.jpg" width="240"/> | Mastodon API feed reader with support for different media types, fullscreen media modal, HTML rewriting | [Demo](https://demo.thi.ng/umbrella/mastodon-feed/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/mastodon-feed) |
|
|
167
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rstream-spreadsheet.png" width="240"/> | rstream based spreadsheet w/ S-expression formula DSL | [Demo](https://demo.thi.ng/umbrella/rstream-spreadsheet/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rstream-spreadsheet) |
|
|
168
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/xml-converter.png" width="240"/> | XML/HTML/SVG to hiccup/JS conversion | [Demo](https://demo.thi.ng/umbrella/xml-converter/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/xml-converter) |
|
|
168
169
|
|
|
169
170
|
## API
|
|
170
171
|
|
package/entities.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const ENTITIES: Record<string, string>;
|
|
|
8
8
|
export declare const RE_ENTITIES: RegExp;
|
|
9
9
|
export declare const ENTITIES_REV: Record<string, string>;
|
|
10
10
|
export declare const RE_ENTITIES_REV: RegExp;
|
|
11
|
+
export declare const RE_ENTITIES_NUM: RegExp;
|
|
11
12
|
export declare const escapeEntities: (src: string) => string;
|
|
12
13
|
export declare const unescapeEntities: (src: string) => string;
|
|
13
14
|
//# sourceMappingURL=entities.d.ts.map
|
package/entities.js
CHANGED
|
@@ -20,11 +20,17 @@ export const ENTITIES = {
|
|
|
20
20
|
"¢": "¢",
|
|
21
21
|
"€": "€",
|
|
22
22
|
"£": "£",
|
|
23
|
+
"¥": "¥",
|
|
24
|
+
"₹": "₹",
|
|
25
|
+
元: "元",
|
|
23
26
|
"§": "§",
|
|
24
27
|
"¶": "¶",
|
|
25
28
|
"©": "©",
|
|
26
29
|
"®": "®",
|
|
27
30
|
"™": "™",
|
|
31
|
+
"℃": "℃",
|
|
32
|
+
"℉": "℉",
|
|
33
|
+
K: "K",
|
|
28
34
|
"◂": "◂",
|
|
29
35
|
"▸": "▸",
|
|
30
36
|
"▴": "▴",
|
|
@@ -42,6 +48,25 @@ export const ENTITIES = {
|
|
|
42
48
|
"¹": "¹",
|
|
43
49
|
"²": "²",
|
|
44
50
|
"³": "³",
|
|
51
|
+
"½": "½",
|
|
52
|
+
"⅓": "⅓",
|
|
53
|
+
"⅔": "⅔",
|
|
54
|
+
"¼": "¼",
|
|
55
|
+
"¾": "¾",
|
|
56
|
+
"⅕": "⅕",
|
|
57
|
+
"⅙": "⅙",
|
|
58
|
+
"⅛": "⅛",
|
|
59
|
+
Ä: "Ä",
|
|
60
|
+
Ë: "Ë",
|
|
61
|
+
Ï: "Ï",
|
|
62
|
+
Ö: "Ö",
|
|
63
|
+
Ü: "Ü",
|
|
64
|
+
ä: "ä",
|
|
65
|
+
ë: "ë",
|
|
66
|
+
ï: "ï",
|
|
67
|
+
ö: "ö",
|
|
68
|
+
ü: "ü",
|
|
69
|
+
ß: "ß",
|
|
45
70
|
α: "α",
|
|
46
71
|
β: "β",
|
|
47
72
|
γ: "γ",
|
|
@@ -88,6 +113,9 @@ export const ENTITIES = {
|
|
|
88
113
|
export const RE_ENTITIES = new RegExp(`[${Object.keys(ENTITIES).join("")}]`, "gu");
|
|
89
114
|
export const ENTITIES_REV = Object.entries(ENTITIES).reduce((acc, [k, v]) => ((acc[v] = k), acc), {});
|
|
90
115
|
export const RE_ENTITIES_REV = new RegExp(`(${Object.keys(ENTITIES_REV).join("|")})`, "g");
|
|
116
|
+
export const RE_ENTITIES_NUM = /&#(x?)([0-9a-f]+);/gi;
|
|
91
117
|
const $esc = (re, index) => (src) => src.replace(re, (x) => index[x]);
|
|
92
118
|
export const escapeEntities = $esc(RE_ENTITIES, ENTITIES);
|
|
93
|
-
export const unescapeEntities =
|
|
119
|
+
export const unescapeEntities = (src) => src
|
|
120
|
+
.replace(RE_ENTITIES_REV, (x) => ENTITIES_REV[x])
|
|
121
|
+
.replace(RE_ENTITIES_NUM, (_, hex, x) => String.fromCharCode(parseInt(x, hex ? 16 : 10)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/strings",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Various string formatting & utility functions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -200,5 +200,5 @@
|
|
|
200
200
|
"thi.ng": {
|
|
201
201
|
"year": 2015
|
|
202
202
|
},
|
|
203
|
-
"gitHead": "
|
|
203
|
+
"gitHead": "b2ef5a1b8932d067af4ec2fc7da03d59d6868dc7\n"
|
|
204
204
|
}
|
package/units.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export declare const bytes: Stringer<number>;
|
|
|
6
6
|
export declare const seconds: Stringer<number>;
|
|
7
7
|
export declare const meters: Stringer<number>;
|
|
8
8
|
export declare const grams: Stringer<number>;
|
|
9
|
+
export declare const unitless: Stringer<number>;
|
|
9
10
|
export {};
|
|
10
11
|
//# sourceMappingURL=units.d.ts.map
|
package/units.js
CHANGED
|
@@ -66,3 +66,16 @@ export const grams = units([
|
|
|
66
66
|
[1e9, " kt"],
|
|
67
67
|
[1e12, " Mt"],
|
|
68
68
|
], " g", 2);
|
|
69
|
+
export const unitless = units([
|
|
70
|
+
[1e-15, "f", 1],
|
|
71
|
+
[1e-12, "p", 1],
|
|
72
|
+
[1e-9, "n", 1],
|
|
73
|
+
[1e-6, "µ", 1],
|
|
74
|
+
[1e-3, "m", 1],
|
|
75
|
+
[1, ""],
|
|
76
|
+
[1e3, "k", 1],
|
|
77
|
+
[1e6, "M", 1],
|
|
78
|
+
[1e9, "G", 1],
|
|
79
|
+
[1e12, "T", 1],
|
|
80
|
+
[1e15, "P", 1],
|
|
81
|
+
], "", 0);
|