@thi.ng/strings 3.3.1 → 3.3.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 +1 -1
- package/README.md +1 -1
- 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 +1 -1
- 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 +10 -10
- package/ruler.d.ts +9 -9
- package/ruler.js +9 -9
- package/slugify.d.ts +1 -1
- package/slugify.js +1 -1
- 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 +8 -8
- package/word-wrap.d.ts +7 -7
- package/word-wrap.js +11 -11
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
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
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.2",
|
|
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.4",
|
|
38
|
+
"@thi.ng/errors": "^2.1.4",
|
|
39
|
+
"@thi.ng/hex": "^2.1.4",
|
|
40
|
+
"@thi.ng/memoize": "^3.1.4"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@microsoft/api-extractor": "^7.19.
|
|
44
|
-
"@thi.ng/testament": "^0.2.
|
|
43
|
+
"@microsoft/api-extractor": "^7.19.4",
|
|
44
|
+
"@thi.ng/testament": "^0.2.4",
|
|
45
45
|
"rimraf": "^3.0.2",
|
|
46
46
|
"tools": "^0.0.1",
|
|
47
|
-
"typedoc": "^0.22.
|
|
48
|
-
"typescript": "^4.
|
|
47
|
+
"typedoc": "^0.22.13",
|
|
48
|
+
"typescript": "^4.6.2"
|
|
49
49
|
},
|
|
50
50
|
"keywords": [
|
|
51
51
|
"ansi",
|
|
@@ -200,5 +200,5 @@
|
|
|
200
200
|
"thi.ng": {
|
|
201
201
|
"year": 2015
|
|
202
202
|
},
|
|
203
|
-
"gitHead": "
|
|
203
|
+
"gitHead": "0fc692a3225c068aacafdc4cb6140cf603c67ad8\n"
|
|
204
204
|
}
|
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,10 +12,10 @@ 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
20
|
export const ruler = (width, major = 5, a = "|", b = "'") => repeat(a + repeat(b, major - 1), Math.ceil(width / major)).substr(0, width);
|
|
21
21
|
/**
|
|
@@ -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/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;
|
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
|
*/
|
|
@@ -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");
|