@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 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
@@ -142,7 +142,7 @@ node --experimental-repl-await
142
142
  > const strings = await import("@thi.ng/strings");
143
143
  ```
144
144
 
145
- Package sizes (gzipped, pre-treeshake): ESM: 4.12 KB
145
+ Package sizes (gzipped, pre-treeshake): ESM: 4.38 KB
146
146
 
147
147
  ## Dependencies
148
148
 
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
+ "&": "&amp;",
3
+ "<": "&lt;",
4
+ ">": "&gt;",
5
+ '"': "&quot;",
6
+ "'": "&apos;",
7
+ "—": "&mdash;",
8
+ "–": "&ndash;",
9
+ "…": "&hellip;",
10
+ "¢": "&cent;",
11
+ "€": "&euro;",
12
+ "£": "&pound;",
13
+ "§": "&sect;",
14
+ "©": "&copy;",
15
+ "®": "&reg;",
16
+ "™": "&trade;",
17
+ "\xa0": "&nbsp;",
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
@@ -3,6 +3,7 @@ export * from "./ansi.js";
3
3
  export * from "./case.js";
4
4
  export * from "./center.js";
5
5
  export * from "./cursor.js";
6
+ export * from "./entities.js";
6
7
  export * from "./escape.js";
7
8
  export * from "./float.js";
8
9
  export * from "./format.js";
package/index.js CHANGED
@@ -3,6 +3,7 @@ export * from "./ansi.js";
3
3
  export * from "./case.js";
4
4
  export * from "./center.js";
5
5
  export * from "./cursor.js";
6
+ export * from "./entities.js";
6
7
  export * from "./escape.js";
7
8
  export * from "./float.js";
8
9
  export * from "./format.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/strings",
3
- "version": "3.0.3",
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.3",
38
- "@thi.ng/errors": "^2.0.3",
39
- "@thi.ng/hex": "^2.0.3",
40
- "@thi.ng/memoize": "^3.0.3"
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.3"
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": "1fb38cac74d6c009d96855c28784a267a81badf1"
195
+ "gitHead": "9ff00a103f76cc4917ef3f244132e218f2300a05"
193
196
  }