@thi.ng/strings 3.0.0 → 3.1.2
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 +51 -0
- package/README.md +4 -3
- package/case.d.ts +1 -1
- package/center.d.ts +1 -1
- package/center.js +2 -2
- package/entities.d.ts +7 -0
- package/entities.js +24 -0
- package/escape.js +1 -1
- package/float.d.ts +1 -1
- package/float.js +1 -1
- package/groups.js +1 -1
- package/hollerith.d.ts +1 -1
- package/index.d.ts +36 -35
- package/index.js +36 -35
- package/int.d.ts +1 -1
- package/join.d.ts +1 -1
- package/package.json +13 -7
- package/pad-left.js +1 -1
- package/pad-right.js +1 -1
- package/percent.d.ts +1 -1
- package/radix.d.ts +1 -1
- package/radix.js +1 -1
- package/ruler.js +1 -1
- package/slugify.d.ts +1 -1
- package/stringify.d.ts +1 -1
- package/tabs.js +1 -1
- package/trim.d.ts +1 -1
- package/truncate-left.d.ts +1 -1
- package/truncate.d.ts +1 -1
- package/units.d.ts +1 -1
- package/vector.d.ts +1 -1
- package/vector.js +1 -1
- package/word-wrap.d.ts +1 -1
- package/word-wrap.js +4 -4
- package/wrap.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,57 @@
|
|
|
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.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/strings@3.1.1...@thi.ng/strings@3.1.2) (2021-10-28)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @thi.ng/strings
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/strings@3.1.0...@thi.ng/strings@3.1.1) (2021-10-28)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @thi.ng/strings
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [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)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **strings:** migrate/add entities, regexes, fns ([57c246d](https://github.com/thi-ng/umbrella/commit/57c246df06279a2e70cfb28ce34ff8d9666b0199))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [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)
|
|
34
|
+
|
|
35
|
+
**Note:** Version bump only for package @thi.ng/strings
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## [3.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/strings@3.0.1...@thi.ng/strings@3.0.2) (2021-10-15)
|
|
42
|
+
|
|
43
|
+
**Note:** Version bump only for package @thi.ng/strings
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## [3.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/strings@3.0.0...@thi.ng/strings@3.0.1) (2021-10-13)
|
|
50
|
+
|
|
51
|
+
**Note:** Version bump only for package @thi.ng/strings
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
6
57
|
# [3.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/strings@2.1.7...@thi.ng/strings@3.0.0) (2021-10-12)
|
|
7
58
|
|
|
8
59
|
|
package/README.md
CHANGED
|
@@ -133,15 +133,16 @@ ES module import:
|
|
|
133
133
|
|
|
134
134
|
[Skypack documentation](https://docs.skypack.dev/)
|
|
135
135
|
|
|
136
|
-
For
|
|
136
|
+
For Node.js REPL:
|
|
137
137
|
|
|
138
138
|
```text
|
|
139
|
-
|
|
139
|
+
# with flag only for < v16
|
|
140
|
+
node --experimental-repl-await
|
|
140
141
|
|
|
141
142
|
> const strings = await import("@thi.ng/strings");
|
|
142
143
|
```
|
|
143
144
|
|
|
144
|
-
Package sizes (gzipped, pre-treeshake): ESM: 4.
|
|
145
|
+
Package sizes (gzipped, pre-treeshake): ESM: 4.38 KB
|
|
145
146
|
|
|
146
147
|
## Dependencies
|
|
147
148
|
|
package/case.d.ts
CHANGED
package/center.d.ts
CHANGED
package/center.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memoizeJ } from "@thi.ng/memoize/memoizej";
|
|
2
|
-
import { repeat } from "./repeat";
|
|
3
|
-
import { truncate } from "./truncate";
|
|
2
|
+
import { repeat } from "./repeat.js";
|
|
3
|
+
import { truncate } from "./truncate.js";
|
|
4
4
|
/**
|
|
5
5
|
* Returns stringer which pads given input with `ch` (default: space) on
|
|
6
6
|
* both sides and returns fixed width string of given `lineWidth`.
|
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/escape.js
CHANGED
package/float.d.ts
CHANGED
package/float.js
CHANGED
package/groups.js
CHANGED
package/hollerith.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
export * from "./api";
|
|
2
|
-
export * from "./ansi";
|
|
3
|
-
export * from "./case";
|
|
4
|
-
export * from "./center";
|
|
5
|
-
export * from "./cursor";
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
16
|
-
export * from "./pad-
|
|
17
|
-
export * from "./
|
|
18
|
-
export * from "./
|
|
19
|
-
export * from "./
|
|
20
|
-
export * from "./
|
|
21
|
-
export * from "./
|
|
22
|
-
export * from "./
|
|
23
|
-
export * from "./
|
|
24
|
-
export * from "./
|
|
25
|
-
export * from "./
|
|
26
|
-
export * from "./
|
|
27
|
-
export * from "./
|
|
28
|
-
export * from "./
|
|
29
|
-
export * from "./
|
|
30
|
-
export * from "./truncate
|
|
31
|
-
export * from "./
|
|
32
|
-
export * from "./
|
|
33
|
-
export * from "./
|
|
34
|
-
export * from "./
|
|
35
|
-
export * from "./
|
|
1
|
+
export * from "./api.js";
|
|
2
|
+
export * from "./ansi.js";
|
|
3
|
+
export * from "./case.js";
|
|
4
|
+
export * from "./center.js";
|
|
5
|
+
export * from "./cursor.js";
|
|
6
|
+
export * from "./entities.js";
|
|
7
|
+
export * from "./escape.js";
|
|
8
|
+
export * from "./float.js";
|
|
9
|
+
export * from "./format.js";
|
|
10
|
+
export * from "./groups.js";
|
|
11
|
+
export * from "./hollerith.js";
|
|
12
|
+
export * from "./initials.js";
|
|
13
|
+
export * from "./int.js";
|
|
14
|
+
export * from "./interpolate.js";
|
|
15
|
+
export * from "./join.js";
|
|
16
|
+
export * from "./pad-left.js";
|
|
17
|
+
export * from "./pad-right.js";
|
|
18
|
+
export * from "./parse.js";
|
|
19
|
+
export * from "./percent.js";
|
|
20
|
+
export * from "./radix.js";
|
|
21
|
+
export * from "./range.js";
|
|
22
|
+
export * from "./repeat.js";
|
|
23
|
+
export * from "./ruler.js";
|
|
24
|
+
export * from "./slugify.js";
|
|
25
|
+
export * from "./splice.js";
|
|
26
|
+
export * from "./split.js";
|
|
27
|
+
export * from "./stringify.js";
|
|
28
|
+
export * from "./tabs.js";
|
|
29
|
+
export * from "./trim.js";
|
|
30
|
+
export * from "./truncate.js";
|
|
31
|
+
export * from "./truncate-left.js";
|
|
32
|
+
export * from "./units.js";
|
|
33
|
+
export * from "./uuid.js";
|
|
34
|
+
export * from "./vector.js";
|
|
35
|
+
export * from "./wrap.js";
|
|
36
|
+
export * from "./word-wrap.js";
|
|
36
37
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
export * from "./api";
|
|
2
|
-
export * from "./ansi";
|
|
3
|
-
export * from "./case";
|
|
4
|
-
export * from "./center";
|
|
5
|
-
export * from "./cursor";
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
16
|
-
export * from "./pad-
|
|
17
|
-
export * from "./
|
|
18
|
-
export * from "./
|
|
19
|
-
export * from "./
|
|
20
|
-
export * from "./
|
|
21
|
-
export * from "./
|
|
22
|
-
export * from "./
|
|
23
|
-
export * from "./
|
|
24
|
-
export * from "./
|
|
25
|
-
export * from "./
|
|
26
|
-
export * from "./
|
|
27
|
-
export * from "./
|
|
28
|
-
export * from "./
|
|
29
|
-
export * from "./
|
|
30
|
-
export * from "./truncate
|
|
31
|
-
export * from "./
|
|
32
|
-
export * from "./
|
|
33
|
-
export * from "./
|
|
34
|
-
export * from "./
|
|
35
|
-
export * from "./
|
|
1
|
+
export * from "./api.js";
|
|
2
|
+
export * from "./ansi.js";
|
|
3
|
+
export * from "./case.js";
|
|
4
|
+
export * from "./center.js";
|
|
5
|
+
export * from "./cursor.js";
|
|
6
|
+
export * from "./entities.js";
|
|
7
|
+
export * from "./escape.js";
|
|
8
|
+
export * from "./float.js";
|
|
9
|
+
export * from "./format.js";
|
|
10
|
+
export * from "./groups.js";
|
|
11
|
+
export * from "./hollerith.js";
|
|
12
|
+
export * from "./initials.js";
|
|
13
|
+
export * from "./int.js";
|
|
14
|
+
export * from "./interpolate.js";
|
|
15
|
+
export * from "./join.js";
|
|
16
|
+
export * from "./pad-left.js";
|
|
17
|
+
export * from "./pad-right.js";
|
|
18
|
+
export * from "./parse.js";
|
|
19
|
+
export * from "./percent.js";
|
|
20
|
+
export * from "./radix.js";
|
|
21
|
+
export * from "./range.js";
|
|
22
|
+
export * from "./repeat.js";
|
|
23
|
+
export * from "./ruler.js";
|
|
24
|
+
export * from "./slugify.js";
|
|
25
|
+
export * from "./splice.js";
|
|
26
|
+
export * from "./split.js";
|
|
27
|
+
export * from "./stringify.js";
|
|
28
|
+
export * from "./tabs.js";
|
|
29
|
+
export * from "./trim.js";
|
|
30
|
+
export * from "./truncate.js";
|
|
31
|
+
export * from "./truncate-left.js";
|
|
32
|
+
export * from "./units.js";
|
|
33
|
+
export * from "./uuid.js";
|
|
34
|
+
export * from "./vector.js";
|
|
35
|
+
export * from "./wrap.js";
|
|
36
|
+
export * from "./word-wrap.js";
|
package/int.d.ts
CHANGED
package/join.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/strings",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.2",
|
|
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.6",
|
|
38
|
+
"@thi.ng/errors": "^2.0.6",
|
|
39
|
+
"@thi.ng/hex": "^2.0.6",
|
|
40
|
+
"@thi.ng/memoize": "^3.0.6"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@thi.ng/testament": "^0.1.
|
|
43
|
+
"@thi.ng/testament": "^0.1.6"
|
|
44
44
|
},
|
|
45
45
|
"keywords": [
|
|
46
46
|
"ansi",
|
|
@@ -69,6 +69,9 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
|
+
"engines": {
|
|
73
|
+
"node": ">=12.7"
|
|
74
|
+
},
|
|
72
75
|
"files": [
|
|
73
76
|
"*.js",
|
|
74
77
|
"*.d.ts"
|
|
@@ -92,6 +95,9 @@
|
|
|
92
95
|
"./cursor": {
|
|
93
96
|
"import": "./cursor.js"
|
|
94
97
|
},
|
|
98
|
+
"./entities": {
|
|
99
|
+
"import": "./entities.js"
|
|
100
|
+
},
|
|
95
101
|
"./escape": {
|
|
96
102
|
"import": "./escape.js"
|
|
97
103
|
},
|
|
@@ -186,5 +192,5 @@
|
|
|
186
192
|
"thi.ng": {
|
|
187
193
|
"year": 2015
|
|
188
194
|
},
|
|
189
|
-
"gitHead": "
|
|
195
|
+
"gitHead": "c17a556ad25f6882dfa8f806a1d9e8ed7ac7cd71"
|
|
190
196
|
}
|
package/pad-left.js
CHANGED
package/pad-right.js
CHANGED
package/percent.d.ts
CHANGED
package/radix.d.ts
CHANGED
package/radix.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { U16 as $16, U24 as $24, U32 as $32, U64HL, U8 as $8, } from "@thi.ng/hex";
|
|
2
2
|
import { memoizeJ } from "@thi.ng/memoize/memoizej";
|
|
3
|
-
import { repeat } from "./repeat";
|
|
3
|
+
import { repeat } from "./repeat.js";
|
|
4
4
|
/**
|
|
5
5
|
* Returns a {@link Stringer} which formats given numbers to `radix`, `len` and
|
|
6
6
|
* with optional prefix (not included in `len`).
|
package/ruler.js
CHANGED
package/slugify.d.ts
CHANGED
package/stringify.d.ts
CHANGED
package/tabs.js
CHANGED
package/trim.d.ts
CHANGED
package/truncate-left.d.ts
CHANGED
package/truncate.d.ts
CHANGED
package/units.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Stringer } from "./api";
|
|
1
|
+
import type { Stringer } from "./api.js";
|
|
2
2
|
declare type UnitDefs = [number, string, number?][];
|
|
3
3
|
export declare const units: (exp: UnitDefs, base: string, prec?: number) => Stringer<number>;
|
|
4
4
|
export declare const bits: Stringer<number>;
|
package/vector.d.ts
CHANGED
package/vector.js
CHANGED
package/word-wrap.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IWordSplit, WordWrapOpts } from "./api";
|
|
1
|
+
import type { IWordSplit, WordWrapOpts } from "./api.js";
|
|
2
2
|
/**
|
|
3
3
|
* Internal representation of a single line (for word wrapping purposes). A thin
|
|
4
4
|
* wrapper of individual word and the _logical_ line length (rather than the
|
package/word-wrap.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { lengthAnsi } from "./ansi";
|
|
2
|
-
import { split } from "./split";
|
|
1
|
+
import { lengthAnsi } from "./ansi.js";
|
|
2
|
+
import { split } from "./split.js";
|
|
3
3
|
/**
|
|
4
4
|
* Internal representation of a single line (for word wrapping purposes). A thin
|
|
5
5
|
* wrapper of individual word and the _logical_ line length (rather than the
|
|
@@ -8,9 +8,9 @@ import { split } from "./split";
|
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
10
|
class Line {
|
|
11
|
-
n = 0;
|
|
12
|
-
w = [];
|
|
13
11
|
constructor(word, n) {
|
|
12
|
+
this.n = 0;
|
|
13
|
+
this.w = [];
|
|
14
14
|
word != null && this.add(word, n);
|
|
15
15
|
}
|
|
16
16
|
add(word, n = word.length) {
|
package/wrap.d.ts
CHANGED