@thi.ng/strings 3.3.1 → 3.3.4
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 +7 -1
- package/README.md +2 -2
- package/ansi.d.ts +5 -5
- package/ansi.js +5 -5
- package/api.d.ts +2 -2
- package/case.d.ts +1 -1
- package/case.js +2 -2
- package/center.js +2 -2
- package/escape.d.ts +2 -2
- package/escape.js +2 -2
- package/format.d.ts +3 -3
- package/format.js +3 -3
- package/initials.d.ts +2 -2
- package/initials.js +2 -2
- package/interpolate.d.ts +4 -4
- package/interpolate.js +4 -4
- package/package.json +48 -48
- package/pad-left.js +1 -1
- package/pad-right.js +1 -1
- package/radix.js +1 -1
- package/ruler.d.ts +9 -9
- package/ruler.js +10 -10
- package/slugify.d.ts +1 -1
- package/slugify.js +1 -1
- package/splice.js +2 -2
- package/split.d.ts +3 -3
- package/split.js +3 -3
- package/stringify.d.ts +2 -2
- package/stringify.js +2 -2
- package/tabs.d.ts +8 -8
- package/tabs.js +9 -9
- package/truncate-left.js +1 -1
- package/truncate.js +1 -1
- package/word-wrap.d.ts +7 -7
- package/word-wrap.js +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**:
|
|
3
|
+
- **Last updated**: 2022-05-07T11:33:35Z
|
|
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,12 @@ 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.3.3](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.3.3) (2022-04-07)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- replace deprecated .substr() w/ .substring() ([0710509](https://github.com/thi-ng/umbrella/commit/0710509))
|
|
17
|
+
|
|
12
18
|
## [3.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.3.0) (2021-12-02)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -143,7 +143,7 @@ node --experimental-repl-await
|
|
|
143
143
|
> const strings = await import("@thi.ng/strings");
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
Package sizes (gzipped, pre-treeshake): ESM: 4.
|
|
146
|
+
Package sizes (gzipped, pre-treeshake): ESM: 4.64 KB
|
|
147
147
|
|
|
148
148
|
## Dependencies
|
|
149
149
|
|
|
@@ -209,4 +209,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
209
209
|
|
|
210
210
|
## License
|
|
211
211
|
|
|
212
|
-
© 2015 -
|
|
212
|
+
© 2015 - 2022 Karsten Schmidt // Apache Software License 2.0
|
package/ansi.d.ts
CHANGED
|
@@ -7,32 +7,32 @@
|
|
|
7
7
|
* // 'hello world!'
|
|
8
8
|
* ```
|
|
9
9
|
*
|
|
10
|
-
* @param x
|
|
10
|
+
* @param x -
|
|
11
11
|
*/
|
|
12
12
|
export declare const stripAnsi: (x: string) => string;
|
|
13
13
|
/**
|
|
14
14
|
* Returns true iff `x` contains ANSI control sequences.
|
|
15
15
|
*
|
|
16
|
-
* @param x
|
|
16
|
+
* @param x -
|
|
17
17
|
*/
|
|
18
18
|
export declare const isAnsi: (x: string) => boolean;
|
|
19
19
|
/**
|
|
20
20
|
* Returns true iff `x` starts w/ an ANSI control sequence.
|
|
21
21
|
*
|
|
22
|
-
* @param x
|
|
22
|
+
* @param x -
|
|
23
23
|
*/
|
|
24
24
|
export declare const isAnsiStart: (x: string) => boolean;
|
|
25
25
|
/**
|
|
26
26
|
* Returns true iff `x` ends w/ an ANSI control sequence.
|
|
27
27
|
*
|
|
28
|
-
* @param x
|
|
28
|
+
* @param x -
|
|
29
29
|
*/
|
|
30
30
|
export declare const isAnsiEnd: (x: string) => boolean;
|
|
31
31
|
/**
|
|
32
32
|
* Returns length of `x` excluding any ANSI control sequences (via
|
|
33
33
|
* {@link stripAnsi}).
|
|
34
34
|
*
|
|
35
|
-
* @param x
|
|
35
|
+
* @param x -
|
|
36
36
|
*/
|
|
37
37
|
export declare const lengthAnsi: (x: string) => number;
|
|
38
38
|
//# sourceMappingURL=ansi.d.ts.map
|
package/ansi.js
CHANGED
|
@@ -8,31 +8,31 @@ const RE = /\x1b\[[0-9;]+m/g;
|
|
|
8
8
|
* // 'hello world!'
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* @param x
|
|
11
|
+
* @param x -
|
|
12
12
|
*/
|
|
13
13
|
export const stripAnsi = (x) => x.replace(RE, "");
|
|
14
14
|
/**
|
|
15
15
|
* Returns true iff `x` contains ANSI control sequences.
|
|
16
16
|
*
|
|
17
|
-
* @param x
|
|
17
|
+
* @param x -
|
|
18
18
|
*/
|
|
19
19
|
export const isAnsi = (x) => /\x1b\[[0-9;]+m/i.test(x);
|
|
20
20
|
/**
|
|
21
21
|
* Returns true iff `x` starts w/ an ANSI control sequence.
|
|
22
22
|
*
|
|
23
|
-
* @param x
|
|
23
|
+
* @param x -
|
|
24
24
|
*/
|
|
25
25
|
export const isAnsiStart = (x) => /^\x1b\[[0-9;]+m/i.test(x);
|
|
26
26
|
/**
|
|
27
27
|
* Returns true iff `x` ends w/ an ANSI control sequence.
|
|
28
28
|
*
|
|
29
|
-
* @param x
|
|
29
|
+
* @param x -
|
|
30
30
|
*/
|
|
31
31
|
export const isAnsiEnd = (x) => /\x1b\[[0-9;]+m$/i.test(x);
|
|
32
32
|
/**
|
|
33
33
|
* Returns length of `x` excluding any ANSI control sequences (via
|
|
34
34
|
* {@link stripAnsi}).
|
|
35
35
|
*
|
|
36
|
-
* @param x
|
|
36
|
+
* @param x -
|
|
37
37
|
*/
|
|
38
38
|
export const lengthAnsi = (x) => stripAnsi(x).length;
|
package/api.d.ts
CHANGED
|
@@ -57,8 +57,8 @@ export interface IWordSplit {
|
|
|
57
57
|
* adjusted split position, e.g. taking any control sequences into account
|
|
58
58
|
* (which can't be split).
|
|
59
59
|
*
|
|
60
|
-
* @param word
|
|
61
|
-
* @param pos
|
|
60
|
+
* @param word -
|
|
61
|
+
* @param pos -
|
|
62
62
|
*/
|
|
63
63
|
split: Fn2<string, number, number>;
|
|
64
64
|
}
|
package/case.d.ts
CHANGED
package/case.js
CHANGED
|
@@ -15,7 +15,7 @@ export const lower = (x) => x.toLowerCase();
|
|
|
15
15
|
*
|
|
16
16
|
* @param x - string to transform
|
|
17
17
|
*/
|
|
18
|
-
export const capitalize = (x) => x[0].toUpperCase() + x.
|
|
18
|
+
export const capitalize = (x) => x[0].toUpperCase() + x.substring(1);
|
|
19
19
|
/**
|
|
20
20
|
* Converts a CamelCase string into kebab case, with optional custom
|
|
21
21
|
* delimiter (`-` by default).
|
|
@@ -43,7 +43,7 @@ export const snake = (x) => kebab(x, "_");
|
|
|
43
43
|
/**
|
|
44
44
|
* Uppercase version of {@link snake}.
|
|
45
45
|
*
|
|
46
|
-
* @param x
|
|
46
|
+
* @param x -
|
|
47
47
|
*/
|
|
48
48
|
export const upperSnake = (x) => snake(x).toUpperCase();
|
|
49
49
|
/**
|
package/center.js
CHANGED
|
@@ -28,9 +28,9 @@ export const center = memoizeJ((n, pad = " ") => {
|
|
|
28
28
|
x = x.toString();
|
|
29
29
|
const r = (n - x.length) / 2;
|
|
30
30
|
return x.length < n
|
|
31
|
-
? buf.
|
|
31
|
+
? buf.substring(0, r) +
|
|
32
32
|
x +
|
|
33
|
-
buf.
|
|
33
|
+
buf.substring(0, r + ((n & 1) === (x.length & 1) ? 0 : 1))
|
|
34
34
|
: truncate(n)(x);
|
|
35
35
|
};
|
|
36
36
|
});
|
package/escape.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const ESCAPES_REV: Record<number, string>;
|
|
|
10
10
|
* - Non-BMP chars will be escaped using `\Uxxxxxxxx`
|
|
11
11
|
* - Chars outside 0x20 - 0x7e range will be escaped using `\uxxxxx`
|
|
12
12
|
*
|
|
13
|
-
* @param src
|
|
13
|
+
* @param src -
|
|
14
14
|
*/
|
|
15
15
|
export declare const escape: (src: string) => string;
|
|
16
16
|
/**
|
|
@@ -31,7 +31,7 @@ export declare const escape: (src: string) => string;
|
|
|
31
31
|
* // '😎'
|
|
32
32
|
* ```
|
|
33
33
|
*
|
|
34
|
-
* @param src
|
|
34
|
+
* @param src -
|
|
35
35
|
*/
|
|
36
36
|
export declare const unescape: (src: string) => string;
|
|
37
37
|
//# sourceMappingURL=escape.d.ts.map
|
package/escape.js
CHANGED
|
@@ -33,7 +33,7 @@ export const ESCAPES_REV = {
|
|
|
33
33
|
* - Non-BMP chars will be escaped using `\Uxxxxxxxx`
|
|
34
34
|
* - Chars outside 0x20 - 0x7e range will be escaped using `\uxxxxx`
|
|
35
35
|
*
|
|
36
|
-
* @param src
|
|
36
|
+
* @param src -
|
|
37
37
|
*/
|
|
38
38
|
export const escape = (src) => src
|
|
39
39
|
.replace(/[\0\b\t\n\v\f\r'"\\]/g, (x) => `\\${ESCAPES_REV[x.charCodeAt(0)]}`)
|
|
@@ -57,7 +57,7 @@ export const escape = (src) => src
|
|
|
57
57
|
* // '😎'
|
|
58
58
|
* ```
|
|
59
59
|
*
|
|
60
|
-
* @param src
|
|
60
|
+
* @param src -
|
|
61
61
|
*/
|
|
62
62
|
export const unescape = (src) => src
|
|
63
63
|
.replace(/\\u([0-9a-fA-F]{4})/g, (_, id) => String.fromCharCode(parseInt(id, 16)))
|
package/format.d.ts
CHANGED
|
@@ -2,20 +2,20 @@ export declare const format: (fmt: any[], ...args: any[]) => string;
|
|
|
2
2
|
/**
|
|
3
3
|
* HOF version of {@link format}.
|
|
4
4
|
*
|
|
5
|
-
* @param fmt
|
|
5
|
+
* @param fmt -
|
|
6
6
|
*/
|
|
7
7
|
export declare const defFormat: (fmt: any[]) => (...args: any[]) => string;
|
|
8
8
|
/**
|
|
9
9
|
* Helper for {@link format} which ignores argument and always returns
|
|
10
10
|
* an empty string.
|
|
11
11
|
*
|
|
12
|
-
* @param _
|
|
12
|
+
* @param _ -
|
|
13
13
|
*/
|
|
14
14
|
export declare const ignore: (_: any) => string;
|
|
15
15
|
/**
|
|
16
16
|
* Helper for {@link format} which coerces `x` to a string.
|
|
17
17
|
*
|
|
18
|
-
* @param x
|
|
18
|
+
* @param x -
|
|
19
19
|
*/
|
|
20
20
|
export declare const str: (x: any) => string;
|
|
21
21
|
//# sourceMappingURL=format.d.ts.map
|
package/format.js
CHANGED
|
@@ -10,19 +10,19 @@ export const format = (fmt, ...args) => {
|
|
|
10
10
|
/**
|
|
11
11
|
* HOF version of {@link format}.
|
|
12
12
|
*
|
|
13
|
-
* @param fmt
|
|
13
|
+
* @param fmt -
|
|
14
14
|
*/
|
|
15
15
|
export const defFormat = (fmt) => (...args) => format(fmt, ...args);
|
|
16
16
|
/**
|
|
17
17
|
* Helper for {@link format} which ignores argument and always returns
|
|
18
18
|
* an empty string.
|
|
19
19
|
*
|
|
20
|
-
* @param _
|
|
20
|
+
* @param _ -
|
|
21
21
|
*/
|
|
22
22
|
export const ignore = (_) => "";
|
|
23
23
|
/**
|
|
24
24
|
* Helper for {@link format} which coerces `x` to a string.
|
|
25
25
|
*
|
|
26
|
-
* @param x
|
|
26
|
+
* @param x -
|
|
27
27
|
*/
|
|
28
28
|
export const str = (x) => String(x);
|
package/initials.d.ts
CHANGED
package/initials.js
CHANGED
package/interpolate.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ import type { IObjectOf, NumOrString } from "@thi.ng/api";
|
|
|
10
10
|
* // "let a: number = 42;"
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
|
-
* @param src
|
|
14
|
-
* @param args
|
|
13
|
+
* @param src -
|
|
14
|
+
* @param args -
|
|
15
15
|
*/
|
|
16
16
|
export declare const interpolate: (src: string, ...args: any[]) => string;
|
|
17
17
|
/**
|
|
@@ -27,8 +27,8 @@ export declare const interpolate: (src: string, ...args: any[]) => string;
|
|
|
27
27
|
* // "let a: number = 42;"
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
|
-
* @param src
|
|
31
|
-
* @param keys
|
|
30
|
+
* @param src -
|
|
31
|
+
* @param keys -
|
|
32
32
|
*/
|
|
33
33
|
export declare const interpolateKeys: (src: string, keys: IObjectOf<NumOrString>) => string;
|
|
34
34
|
//# sourceMappingURL=interpolate.d.ts.map
|
package/interpolate.js
CHANGED
|
@@ -12,8 +12,8 @@ const TPL_K = /\{([a-z0-9_.-]+)\}/gi;
|
|
|
12
12
|
* // "let a: number = 42;"
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
* @param src
|
|
16
|
-
* @param args
|
|
15
|
+
* @param src -
|
|
16
|
+
* @param args -
|
|
17
17
|
*/
|
|
18
18
|
export const interpolate = (src, ...args) => args.length > 0
|
|
19
19
|
? src.replace(TPL, (_, id) => String(args[parseInt(id, 10)]))
|
|
@@ -31,8 +31,8 @@ export const interpolate = (src, ...args) => args.length > 0
|
|
|
31
31
|
* // "let a: number = 42;"
|
|
32
32
|
* ```
|
|
33
33
|
*
|
|
34
|
-
* @param src
|
|
35
|
-
* @param keys
|
|
34
|
+
* @param src -
|
|
35
|
+
* @param keys -
|
|
36
36
|
*/
|
|
37
37
|
export const interpolateKeys = (src, keys) => src.replace(TPL_K, (_, id) => keys[id] != undefined
|
|
38
38
|
? String(keys[id])
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/strings",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.4",
|
|
4
4
|
"description": "Various string formatting & utility functions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.3.
|
|
38
|
-
"@thi.ng/errors": "^2.1.
|
|
39
|
-
"@thi.ng/hex": "^2.1.
|
|
40
|
-
"@thi.ng/memoize": "^3.1.
|
|
37
|
+
"@thi.ng/api": "^8.3.6",
|
|
38
|
+
"@thi.ng/errors": "^2.1.6",
|
|
39
|
+
"@thi.ng/hex": "^2.1.6",
|
|
40
|
+
"@thi.ng/memoize": "^3.1.6"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@microsoft/api-extractor": "^7.
|
|
44
|
-
"@thi.ng/testament": "^0.2.
|
|
43
|
+
"@microsoft/api-extractor": "^7.23.1",
|
|
44
|
+
"@thi.ng/testament": "^0.2.6",
|
|
45
45
|
"rimraf": "^3.0.2",
|
|
46
46
|
"tools": "^0.0.1",
|
|
47
|
-
"typedoc": "^0.22.
|
|
48
|
-
"typescript": "^4.
|
|
47
|
+
"typedoc": "^0.22.15",
|
|
48
|
+
"typescript": "^4.6.4"
|
|
49
49
|
},
|
|
50
50
|
"keywords": [
|
|
51
51
|
"ansi",
|
|
@@ -83,122 +83,122 @@
|
|
|
83
83
|
],
|
|
84
84
|
"exports": {
|
|
85
85
|
".": {
|
|
86
|
-
"
|
|
86
|
+
"default": "./index.js"
|
|
87
87
|
},
|
|
88
88
|
"./ansi": {
|
|
89
|
-
"
|
|
89
|
+
"default": "./ansi.js"
|
|
90
90
|
},
|
|
91
91
|
"./api": {
|
|
92
|
-
"
|
|
92
|
+
"default": "./api.js"
|
|
93
93
|
},
|
|
94
94
|
"./case": {
|
|
95
|
-
"
|
|
95
|
+
"default": "./case.js"
|
|
96
96
|
},
|
|
97
97
|
"./center": {
|
|
98
|
-
"
|
|
98
|
+
"default": "./center.js"
|
|
99
99
|
},
|
|
100
100
|
"./currency": {
|
|
101
|
-
"
|
|
101
|
+
"default": "./currency.js"
|
|
102
102
|
},
|
|
103
103
|
"./cursor": {
|
|
104
|
-
"
|
|
104
|
+
"default": "./cursor.js"
|
|
105
105
|
},
|
|
106
106
|
"./entities": {
|
|
107
|
-
"
|
|
107
|
+
"default": "./entities.js"
|
|
108
108
|
},
|
|
109
109
|
"./escape": {
|
|
110
|
-
"
|
|
110
|
+
"default": "./escape.js"
|
|
111
111
|
},
|
|
112
112
|
"./float": {
|
|
113
|
-
"
|
|
113
|
+
"default": "./float.js"
|
|
114
114
|
},
|
|
115
115
|
"./format": {
|
|
116
|
-
"
|
|
116
|
+
"default": "./format.js"
|
|
117
117
|
},
|
|
118
118
|
"./groups": {
|
|
119
|
-
"
|
|
119
|
+
"default": "./groups.js"
|
|
120
120
|
},
|
|
121
121
|
"./hollerith": {
|
|
122
|
-
"
|
|
122
|
+
"default": "./hollerith.js"
|
|
123
123
|
},
|
|
124
124
|
"./initials": {
|
|
125
|
-
"
|
|
125
|
+
"default": "./initials.js"
|
|
126
126
|
},
|
|
127
127
|
"./int": {
|
|
128
|
-
"
|
|
128
|
+
"default": "./int.js"
|
|
129
129
|
},
|
|
130
130
|
"./interpolate": {
|
|
131
|
-
"
|
|
131
|
+
"default": "./interpolate.js"
|
|
132
132
|
},
|
|
133
133
|
"./join": {
|
|
134
|
-
"
|
|
134
|
+
"default": "./join.js"
|
|
135
135
|
},
|
|
136
136
|
"./pad-left": {
|
|
137
|
-
"
|
|
137
|
+
"default": "./pad-left.js"
|
|
138
138
|
},
|
|
139
139
|
"./pad-right": {
|
|
140
|
-
"
|
|
140
|
+
"default": "./pad-right.js"
|
|
141
141
|
},
|
|
142
142
|
"./parse": {
|
|
143
|
-
"
|
|
143
|
+
"default": "./parse.js"
|
|
144
144
|
},
|
|
145
145
|
"./percent": {
|
|
146
|
-
"
|
|
146
|
+
"default": "./percent.js"
|
|
147
147
|
},
|
|
148
148
|
"./radix": {
|
|
149
|
-
"
|
|
149
|
+
"default": "./radix.js"
|
|
150
150
|
},
|
|
151
151
|
"./range": {
|
|
152
|
-
"
|
|
152
|
+
"default": "./range.js"
|
|
153
153
|
},
|
|
154
154
|
"./repeat": {
|
|
155
|
-
"
|
|
155
|
+
"default": "./repeat.js"
|
|
156
156
|
},
|
|
157
157
|
"./ruler": {
|
|
158
|
-
"
|
|
158
|
+
"default": "./ruler.js"
|
|
159
159
|
},
|
|
160
160
|
"./slugify": {
|
|
161
|
-
"
|
|
161
|
+
"default": "./slugify.js"
|
|
162
162
|
},
|
|
163
163
|
"./splice": {
|
|
164
|
-
"
|
|
164
|
+
"default": "./splice.js"
|
|
165
165
|
},
|
|
166
166
|
"./split": {
|
|
167
|
-
"
|
|
167
|
+
"default": "./split.js"
|
|
168
168
|
},
|
|
169
169
|
"./stringify": {
|
|
170
|
-
"
|
|
170
|
+
"default": "./stringify.js"
|
|
171
171
|
},
|
|
172
172
|
"./tabs": {
|
|
173
|
-
"
|
|
173
|
+
"default": "./tabs.js"
|
|
174
174
|
},
|
|
175
175
|
"./trim": {
|
|
176
|
-
"
|
|
176
|
+
"default": "./trim.js"
|
|
177
177
|
},
|
|
178
178
|
"./truncate-left": {
|
|
179
|
-
"
|
|
179
|
+
"default": "./truncate-left.js"
|
|
180
180
|
},
|
|
181
181
|
"./truncate": {
|
|
182
|
-
"
|
|
182
|
+
"default": "./truncate.js"
|
|
183
183
|
},
|
|
184
184
|
"./units": {
|
|
185
|
-
"
|
|
185
|
+
"default": "./units.js"
|
|
186
186
|
},
|
|
187
187
|
"./uuid": {
|
|
188
|
-
"
|
|
188
|
+
"default": "./uuid.js"
|
|
189
189
|
},
|
|
190
190
|
"./vector": {
|
|
191
|
-
"
|
|
191
|
+
"default": "./vector.js"
|
|
192
192
|
},
|
|
193
193
|
"./word-wrap": {
|
|
194
|
-
"
|
|
194
|
+
"default": "./word-wrap.js"
|
|
195
195
|
},
|
|
196
196
|
"./wrap": {
|
|
197
|
-
"
|
|
197
|
+
"default": "./wrap.js"
|
|
198
198
|
}
|
|
199
199
|
},
|
|
200
200
|
"thi.ng": {
|
|
201
201
|
"year": 2015
|
|
202
202
|
},
|
|
203
|
-
"gitHead": "
|
|
203
|
+
"gitHead": "cf084be5fd5932226054d2dd32bad35481379f5d\n"
|
|
204
204
|
}
|
package/pad-left.js
CHANGED
package/pad-right.js
CHANGED
package/radix.js
CHANGED
|
@@ -17,7 +17,7 @@ export const radix = memoizeJ((radix, n, prefix = "") => {
|
|
|
17
17
|
const buf = repeat("0", n);
|
|
18
18
|
return (x) => {
|
|
19
19
|
x = (x >>> 0).toString(radix);
|
|
20
|
-
return prefix + (x.length < n ? buf.
|
|
20
|
+
return prefix + (x.length < n ? buf.substring(x.length) + x : x);
|
|
21
21
|
};
|
|
22
22
|
});
|
|
23
23
|
/**
|
package/ruler.d.ts
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
* // !.......!.......!.......!.......!.......
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
14
|
-
* @param width
|
|
15
|
-
* @param major
|
|
16
|
-
* @param a
|
|
17
|
-
* @param b
|
|
14
|
+
* @param width -
|
|
15
|
+
* @param major -
|
|
16
|
+
* @param a -
|
|
17
|
+
* @param b -
|
|
18
18
|
*/
|
|
19
19
|
export declare const ruler: (width: number, major?: number, a?: string, b?: string) => string;
|
|
20
20
|
/**
|
|
@@ -51,11 +51,11 @@ export declare const ruler: (width: number, major?: number, a?: string, b?: stri
|
|
|
51
51
|
* // + + +
|
|
52
52
|
* ```
|
|
53
53
|
*
|
|
54
|
-
* @param cols
|
|
55
|
-
* @param rows
|
|
56
|
-
* @param w
|
|
57
|
-
* @param h
|
|
58
|
-
* @param chars
|
|
54
|
+
* @param cols -
|
|
55
|
+
* @param rows -
|
|
56
|
+
* @param w -
|
|
57
|
+
* @param h -
|
|
58
|
+
* @param chars -
|
|
59
59
|
*/
|
|
60
60
|
export declare const grid: (cols: number, rows: number, w: number, h: number, [a, b, c, d]?: string) => string;
|
|
61
61
|
//# sourceMappingURL=ruler.d.ts.map
|
package/ruler.js
CHANGED
|
@@ -12,12 +12,12 @@ import { repeat } from "./repeat.js";
|
|
|
12
12
|
* // !.......!.......!.......!.......!.......
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
* @param width
|
|
16
|
-
* @param major
|
|
17
|
-
* @param a
|
|
18
|
-
* @param b
|
|
15
|
+
* @param width -
|
|
16
|
+
* @param major -
|
|
17
|
+
* @param a -
|
|
18
|
+
* @param b -
|
|
19
19
|
*/
|
|
20
|
-
export const ruler = (width, major = 5, a = "|", b = "'") => repeat(a + repeat(b, major - 1), Math.ceil(width / major)).
|
|
20
|
+
export const ruler = (width, major = 5, a = "|", b = "'") => repeat(a + repeat(b, major - 1), Math.ceil(width / major)).substring(0, width);
|
|
21
21
|
/**
|
|
22
22
|
* Returns a grid of given `cols` x `rows` as string, each cell of size `w` x
|
|
23
23
|
* `h`. The optional `chars` can be used to customize the grid.
|
|
@@ -52,11 +52,11 @@ export const ruler = (width, major = 5, a = "|", b = "'") => repeat(a + repeat(b
|
|
|
52
52
|
* // + + +
|
|
53
53
|
* ```
|
|
54
54
|
*
|
|
55
|
-
* @param cols
|
|
56
|
-
* @param rows
|
|
57
|
-
* @param w
|
|
58
|
-
* @param h
|
|
59
|
-
* @param chars
|
|
55
|
+
* @param cols -
|
|
56
|
+
* @param rows -
|
|
57
|
+
* @param w -
|
|
58
|
+
* @param h -
|
|
59
|
+
* @param chars -
|
|
60
60
|
*/
|
|
61
61
|
export const grid = (cols, rows, w, h, [a, b, c, d] = "+-| ") => {
|
|
62
62
|
const major = ruler(cols * w, w, a, b) + a + "\n";
|
package/slugify.d.ts
CHANGED
package/slugify.js
CHANGED
package/splice.js
CHANGED
|
@@ -24,8 +24,8 @@ export const splice = (src, insert, from, to = from) => {
|
|
|
24
24
|
}
|
|
25
25
|
to = Math.max(to, 0);
|
|
26
26
|
return from <= 0
|
|
27
|
-
? insert + src.
|
|
27
|
+
? insert + src.substring(to)
|
|
28
28
|
: from >= src.length
|
|
29
29
|
? src + insert
|
|
30
|
-
: src.
|
|
30
|
+
: src.substring(0, from) + insert + src.substring(to);
|
|
31
31
|
};
|
package/split.d.ts
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* This function is ~2x faster for large strings (benchmarked with 8MB & 16MB
|
|
9
9
|
* inputs), with dramatically lower memory consumption.
|
|
10
10
|
*
|
|
11
|
-
* @param src
|
|
12
|
-
* @param delim
|
|
13
|
-
* @param includeDelim
|
|
11
|
+
* @param src -
|
|
12
|
+
* @param delim -
|
|
13
|
+
* @param includeDelim -
|
|
14
14
|
*/
|
|
15
15
|
export declare function split(src: string, delim?: RegExp | string, includeDelim?: boolean): Generator<string, void, unknown>;
|
|
16
16
|
//# sourceMappingURL=split.d.ts.map
|
package/split.js
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* This function is ~2x faster for large strings (benchmarked with 8MB & 16MB
|
|
9
9
|
* inputs), with dramatically lower memory consumption.
|
|
10
10
|
*
|
|
11
|
-
* @param src
|
|
12
|
-
* @param delim
|
|
13
|
-
* @param includeDelim
|
|
11
|
+
* @param src -
|
|
12
|
+
* @param delim -
|
|
13
|
+
* @param includeDelim -
|
|
14
14
|
*/
|
|
15
15
|
export function* split(src, delim = /\r?\n/g, includeDelim = false) {
|
|
16
16
|
let i = 0;
|
package/stringify.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import type { Stringer } from "./api.js";
|
|
|
5
5
|
* are simply converted using `String(x)`. If `indent` is given, it will be used
|
|
6
6
|
* for `JSON.stringify(x, null, indent)`
|
|
7
7
|
*
|
|
8
|
-
* @param all
|
|
9
|
-
* @param indent
|
|
8
|
+
* @param all -
|
|
9
|
+
* @param indent -
|
|
10
10
|
*/
|
|
11
11
|
export declare const stringify: (all?: boolean, indent?: number | undefined) => Stringer<any>;
|
|
12
12
|
//# sourceMappingURL=stringify.d.ts.map
|
package/stringify.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* are simply converted using `String(x)`. If `indent` is given, it will be used
|
|
5
5
|
* for `JSON.stringify(x, null, indent)`
|
|
6
6
|
*
|
|
7
|
-
* @param all
|
|
8
|
-
* @param indent
|
|
7
|
+
* @param all -
|
|
8
|
+
* @param indent -
|
|
9
9
|
*/
|
|
10
10
|
export const stringify = (all = false, indent) => (x) => all || (typeof x !== "string" && typeof x !== "number")
|
|
11
11
|
? JSON.stringify(x, null, indent)
|
package/tabs.d.ts
CHANGED
|
@@ -15,31 +15,31 @@
|
|
|
15
15
|
* // ^ ^ ^ ^ ^ ^
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
|
-
* @param src
|
|
19
|
-
* @param tabSize
|
|
18
|
+
* @param src -
|
|
19
|
+
* @param tabSize -
|
|
20
20
|
*/
|
|
21
21
|
export declare const tabsToSpaces: (src: string, tabSize?: number) => string;
|
|
22
22
|
/**
|
|
23
23
|
* Takes a single line string and converts all tab characters to spaces, using
|
|
24
24
|
* given `tabSize`.
|
|
25
25
|
*
|
|
26
|
-
* @param line
|
|
27
|
-
* @param tabSize
|
|
26
|
+
* @param line -
|
|
27
|
+
* @param tabSize -
|
|
28
28
|
*/
|
|
29
29
|
export declare const tabsToSpacesLine: (line: string, tabSize?: number) => string;
|
|
30
30
|
/**
|
|
31
31
|
* Multi-line version of {@link spacesToTabsLine}.
|
|
32
32
|
*
|
|
33
|
-
* @param src
|
|
34
|
-
* @param tabSize
|
|
33
|
+
* @param src -
|
|
34
|
+
* @param tabSize -
|
|
35
35
|
*/
|
|
36
36
|
export declare const spacesToTabs: (src: string, tabSize?: number) => string;
|
|
37
37
|
/**
|
|
38
38
|
* Takes a single line string and converts all tab characters to spaces, using
|
|
39
39
|
* given `tabSize`. Inverse op of {@link tabsToSpacesLine}.
|
|
40
40
|
*
|
|
41
|
-
* @param line
|
|
42
|
-
* @param tabSize
|
|
41
|
+
* @param line -
|
|
42
|
+
* @param tabSize -
|
|
43
43
|
*/
|
|
44
44
|
export declare const spacesToTabsLine: (line: string, tabSize?: number) => string;
|
|
45
45
|
//# sourceMappingURL=tabs.d.ts.map
|
package/tabs.js
CHANGED
|
@@ -17,8 +17,8 @@ const nextTab = (x, tabSize) => Math.floor((x + tabSize) / tabSize) * tabSize;
|
|
|
17
17
|
* // ^ ^ ^ ^ ^ ^
|
|
18
18
|
* ```
|
|
19
19
|
*
|
|
20
|
-
* @param src
|
|
21
|
-
* @param tabSize
|
|
20
|
+
* @param src -
|
|
21
|
+
* @param tabSize -
|
|
22
22
|
*/
|
|
23
23
|
export const tabsToSpaces = (src, tabSize = 4) => src
|
|
24
24
|
.split(/\r?\n/g)
|
|
@@ -28,8 +28,8 @@ export const tabsToSpaces = (src, tabSize = 4) => src
|
|
|
28
28
|
* Takes a single line string and converts all tab characters to spaces, using
|
|
29
29
|
* given `tabSize`.
|
|
30
30
|
*
|
|
31
|
-
* @param line
|
|
32
|
-
* @param tabSize
|
|
31
|
+
* @param line -
|
|
32
|
+
* @param tabSize -
|
|
33
33
|
*/
|
|
34
34
|
export const tabsToSpacesLine = (line, tabSize = 4) => {
|
|
35
35
|
let res = "";
|
|
@@ -46,8 +46,8 @@ export const tabsToSpacesLine = (line, tabSize = 4) => {
|
|
|
46
46
|
/**
|
|
47
47
|
* Multi-line version of {@link spacesToTabsLine}.
|
|
48
48
|
*
|
|
49
|
-
* @param src
|
|
50
|
-
* @param tabSize
|
|
49
|
+
* @param src -
|
|
50
|
+
* @param tabSize -
|
|
51
51
|
*/
|
|
52
52
|
export const spacesToTabs = (src, tabSize = 4) => src
|
|
53
53
|
.split(/\r?\n/g)
|
|
@@ -57,8 +57,8 @@ export const spacesToTabs = (src, tabSize = 4) => src
|
|
|
57
57
|
* Takes a single line string and converts all tab characters to spaces, using
|
|
58
58
|
* given `tabSize`. Inverse op of {@link tabsToSpacesLine}.
|
|
59
59
|
*
|
|
60
|
-
* @param line
|
|
61
|
-
* @param tabSize
|
|
60
|
+
* @param line -
|
|
61
|
+
* @param tabSize -
|
|
62
62
|
*/
|
|
63
63
|
export const spacesToTabsLine = (line, tabSize = 4) => {
|
|
64
64
|
const re = /\s{2,}/g;
|
|
@@ -83,5 +83,5 @@ export const spacesToTabsLine = (line, tabSize = 4) => {
|
|
|
83
83
|
}
|
|
84
84
|
i = end;
|
|
85
85
|
}
|
|
86
|
-
return res + line.
|
|
86
|
+
return res + line.substring(i);
|
|
87
87
|
};
|
package/truncate-left.js
CHANGED
package/truncate.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { memoizeJ } from "@thi.ng/memoize/memoizej";
|
|
2
|
-
export const truncate = memoizeJ((n, suffix = "") => (x) => x.length > n ? x.
|
|
2
|
+
export const truncate = memoizeJ((n, suffix = "") => (x) => x.length > n ? x.substring(0, n - suffix.length) + suffix : x);
|
|
3
3
|
/**
|
|
4
4
|
* Alias for {@link truncate}
|
|
5
5
|
*/
|
package/word-wrap.d.ts
CHANGED
|
@@ -28,9 +28,9 @@ export declare const SPLIT_ANSI: IWordSplit;
|
|
|
28
28
|
*
|
|
29
29
|
* @see {@link wordWrap} for main user facing alternative.
|
|
30
30
|
*
|
|
31
|
-
* @param line
|
|
32
|
-
* @param opts
|
|
33
|
-
* @param acc
|
|
31
|
+
* @param line -
|
|
32
|
+
* @param opts -
|
|
33
|
+
* @param acc -
|
|
34
34
|
*
|
|
35
35
|
* @internal
|
|
36
36
|
*/
|
|
@@ -42,16 +42,16 @@ export declare const wordWrapLine: (line: string, opts: Partial<WordWrapOpts>, a
|
|
|
42
42
|
*
|
|
43
43
|
* @see {@link wordWrap} for main user facing alternative.
|
|
44
44
|
*
|
|
45
|
-
* @param lines
|
|
46
|
-
* @param opts
|
|
45
|
+
* @param lines -
|
|
46
|
+
* @param opts -
|
|
47
47
|
*/
|
|
48
48
|
export declare const wordWrapLines: (lines: string, opts: Partial<WordWrapOpts>) => Line[];
|
|
49
49
|
/**
|
|
50
50
|
* Same as {@link wordWrapLines}, but returns wordwrapped result as string. See
|
|
51
51
|
* {@link WordWrapOpts} for options.
|
|
52
52
|
*
|
|
53
|
-
* @param str
|
|
54
|
-
* @param opts
|
|
53
|
+
* @param str -
|
|
54
|
+
* @param opts -
|
|
55
55
|
*/
|
|
56
56
|
export declare const wordWrap: (str: string, opts: Partial<WordWrapOpts>) => string;
|
|
57
57
|
export {};
|
package/word-wrap.js
CHANGED
|
@@ -69,10 +69,10 @@ const append = (acc, word, wordLen, width) => {
|
|
|
69
69
|
* {@link WordWrapOpts.min} chars available and the word is longer than that, it
|
|
70
70
|
* will be placed into a new line (thus minimizing legibility issues).
|
|
71
71
|
*
|
|
72
|
-
* @param word
|
|
73
|
-
* @param opts
|
|
74
|
-
* @param offset
|
|
75
|
-
* @param acc
|
|
72
|
+
* @param word -
|
|
73
|
+
* @param opts -
|
|
74
|
+
* @param offset -
|
|
75
|
+
* @param acc -
|
|
76
76
|
*
|
|
77
77
|
* @internal
|
|
78
78
|
*/
|
|
@@ -87,9 +87,9 @@ const wrapWord = (word, { width, min, hard, splitter }, offset = 0, acc = []) =>
|
|
|
87
87
|
// (maybe) hardwrap long word
|
|
88
88
|
while (hard && len > free) {
|
|
89
89
|
const split = splitter.split(word, free);
|
|
90
|
-
const chunk = word.
|
|
90
|
+
const chunk = word.substring(0, split);
|
|
91
91
|
append(acc, chunk, free, width);
|
|
92
|
-
word = word.
|
|
92
|
+
word = word.substring(split);
|
|
93
93
|
free = width;
|
|
94
94
|
len = splitter.length(word);
|
|
95
95
|
}
|
|
@@ -103,9 +103,9 @@ const wrapWord = (word, { width, min, hard, splitter }, offset = 0, acc = []) =>
|
|
|
103
103
|
*
|
|
104
104
|
* @see {@link wordWrap} for main user facing alternative.
|
|
105
105
|
*
|
|
106
|
-
* @param line
|
|
107
|
-
* @param opts
|
|
108
|
-
* @param acc
|
|
106
|
+
* @param line -
|
|
107
|
+
* @param opts -
|
|
108
|
+
* @param acc -
|
|
109
109
|
*
|
|
110
110
|
* @internal
|
|
111
111
|
*/
|
|
@@ -134,8 +134,8 @@ export const wordWrapLine = (line, opts, acc = []) => {
|
|
|
134
134
|
*
|
|
135
135
|
* @see {@link wordWrap} for main user facing alternative.
|
|
136
136
|
*
|
|
137
|
-
* @param lines
|
|
138
|
-
* @param opts
|
|
137
|
+
* @param lines -
|
|
138
|
+
* @param opts -
|
|
139
139
|
*/
|
|
140
140
|
export const wordWrapLines = (lines, opts) => {
|
|
141
141
|
let acc = [];
|
|
@@ -148,7 +148,7 @@ export const wordWrapLines = (lines, opts) => {
|
|
|
148
148
|
* Same as {@link wordWrapLines}, but returns wordwrapped result as string. See
|
|
149
149
|
* {@link WordWrapOpts} for options.
|
|
150
150
|
*
|
|
151
|
-
* @param str
|
|
152
|
-
* @param opts
|
|
151
|
+
* @param str -
|
|
152
|
+
* @param opts -
|
|
153
153
|
*/
|
|
154
154
|
export const wordWrap = (str, opts) => wordWrapLines(str, opts).join("\n");
|