@thi.ng/strings 2.1.4 → 3.0.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 +128 -209
- package/README.md +14 -6
- package/center.js +1 -1
- package/float.js +1 -1
- package/groups.js +6 -2
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/initials.d.ts +22 -0
- package/initials.js +28 -0
- package/int.js +1 -1
- package/interpolate.js +1 -1
- package/join.js +1 -1
- package/package.json +132 -25
- package/pad-left.js +1 -1
- package/pad-right.js +1 -1
- package/radix.js +1 -1
- package/repeat.js +1 -1
- package/splice.js +1 -1
- package/trim.js +1 -1
- package/truncate-left.js +4 -2
- package/truncate.js +1 -1
- package/units.js +1 -1
- package/vector.js +1 -1
- package/word-wrap.js +9 -3
- package/wrap.js +1 -1
- package/lib/index.js +0 -630
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -1
- package/lib/index.umd.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/strings",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Various string formatting & utility functions",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"module": "./index.js",
|
|
6
|
-
"main": "./lib/index.js",
|
|
7
|
-
"umd:main": "./lib/index.umd.js",
|
|
8
7
|
"typings": "./index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
@@ -24,30 +24,24 @@
|
|
|
24
24
|
"author": "Karsten Schmidt <k+npm@thi.ng>",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "yarn clean &&
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"build:test": "rimraf build && tsc -p test/tsconfig.json",
|
|
31
|
-
"build:check": "tsc --isolatedModules --noEmit",
|
|
32
|
-
"test": "mocha test",
|
|
33
|
-
"cover": "nyc mocha test && nyc report --reporter=lcov",
|
|
34
|
-
"clean": "rimraf *.js *.d.ts *.map .nyc_output build coverage doc lib",
|
|
35
|
-
"doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts",
|
|
36
|
-
"doc": "typedoc --excludePrivate --out doc --theme ../../tools/doc/typedoc-theme src/index.ts",
|
|
27
|
+
"build": "yarn clean && tsc --declaration",
|
|
28
|
+
"clean": "rimraf *.js *.d.ts *.map doc",
|
|
29
|
+
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
37
30
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
|
|
38
|
-
"
|
|
31
|
+
"doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
|
|
32
|
+
"doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
|
|
33
|
+
"pub": "yarn build && yarn publish --access public",
|
|
34
|
+
"test": "testament test"
|
|
39
35
|
},
|
|
40
36
|
"dependencies": {
|
|
41
|
-
"@thi.ng/api": "^
|
|
42
|
-
"@thi.ng/errors": "^
|
|
43
|
-
"@thi.ng/hex": "^0.
|
|
44
|
-
"@thi.ng/memoize": "^
|
|
37
|
+
"@thi.ng/api": "^8.0.0",
|
|
38
|
+
"@thi.ng/errors": "^2.0.0",
|
|
39
|
+
"@thi.ng/hex": "^2.0.0",
|
|
40
|
+
"@thi.ng/memoize": "^3.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@thi.ng/testament": "^0.1.0"
|
|
45
44
|
},
|
|
46
|
-
"files": [
|
|
47
|
-
"*.js",
|
|
48
|
-
"*.d.ts",
|
|
49
|
-
"lib"
|
|
50
|
-
],
|
|
51
45
|
"keywords": [
|
|
52
46
|
"ansi",
|
|
53
47
|
"composition",
|
|
@@ -75,9 +69,122 @@
|
|
|
75
69
|
"publishConfig": {
|
|
76
70
|
"access": "public"
|
|
77
71
|
},
|
|
78
|
-
"
|
|
72
|
+
"files": [
|
|
73
|
+
"*.js",
|
|
74
|
+
"*.d.ts"
|
|
75
|
+
],
|
|
76
|
+
"exports": {
|
|
77
|
+
".": {
|
|
78
|
+
"import": "./index.js"
|
|
79
|
+
},
|
|
80
|
+
"./ansi": {
|
|
81
|
+
"import": "./ansi.js"
|
|
82
|
+
},
|
|
83
|
+
"./api": {
|
|
84
|
+
"import": "./api.js"
|
|
85
|
+
},
|
|
86
|
+
"./case": {
|
|
87
|
+
"import": "./case.js"
|
|
88
|
+
},
|
|
89
|
+
"./center": {
|
|
90
|
+
"import": "./center.js"
|
|
91
|
+
},
|
|
92
|
+
"./cursor": {
|
|
93
|
+
"import": "./cursor.js"
|
|
94
|
+
},
|
|
95
|
+
"./escape": {
|
|
96
|
+
"import": "./escape.js"
|
|
97
|
+
},
|
|
98
|
+
"./float": {
|
|
99
|
+
"import": "./float.js"
|
|
100
|
+
},
|
|
101
|
+
"./format": {
|
|
102
|
+
"import": "./format.js"
|
|
103
|
+
},
|
|
104
|
+
"./groups": {
|
|
105
|
+
"import": "./groups.js"
|
|
106
|
+
},
|
|
107
|
+
"./hollerith": {
|
|
108
|
+
"import": "./hollerith.js"
|
|
109
|
+
},
|
|
110
|
+
"./initials": {
|
|
111
|
+
"import": "./initials.js"
|
|
112
|
+
},
|
|
113
|
+
"./int": {
|
|
114
|
+
"import": "./int.js"
|
|
115
|
+
},
|
|
116
|
+
"./interpolate": {
|
|
117
|
+
"import": "./interpolate.js"
|
|
118
|
+
},
|
|
119
|
+
"./join": {
|
|
120
|
+
"import": "./join.js"
|
|
121
|
+
},
|
|
122
|
+
"./pad-left": {
|
|
123
|
+
"import": "./pad-left.js"
|
|
124
|
+
},
|
|
125
|
+
"./pad-right": {
|
|
126
|
+
"import": "./pad-right.js"
|
|
127
|
+
},
|
|
128
|
+
"./parse": {
|
|
129
|
+
"import": "./parse.js"
|
|
130
|
+
},
|
|
131
|
+
"./percent": {
|
|
132
|
+
"import": "./percent.js"
|
|
133
|
+
},
|
|
134
|
+
"./radix": {
|
|
135
|
+
"import": "./radix.js"
|
|
136
|
+
},
|
|
137
|
+
"./range": {
|
|
138
|
+
"import": "./range.js"
|
|
139
|
+
},
|
|
140
|
+
"./repeat": {
|
|
141
|
+
"import": "./repeat.js"
|
|
142
|
+
},
|
|
143
|
+
"./ruler": {
|
|
144
|
+
"import": "./ruler.js"
|
|
145
|
+
},
|
|
146
|
+
"./slugify": {
|
|
147
|
+
"import": "./slugify.js"
|
|
148
|
+
},
|
|
149
|
+
"./splice": {
|
|
150
|
+
"import": "./splice.js"
|
|
151
|
+
},
|
|
152
|
+
"./split": {
|
|
153
|
+
"import": "./split.js"
|
|
154
|
+
},
|
|
155
|
+
"./stringify": {
|
|
156
|
+
"import": "./stringify.js"
|
|
157
|
+
},
|
|
158
|
+
"./tabs": {
|
|
159
|
+
"import": "./tabs.js"
|
|
160
|
+
},
|
|
161
|
+
"./trim": {
|
|
162
|
+
"import": "./trim.js"
|
|
163
|
+
},
|
|
164
|
+
"./truncate-left": {
|
|
165
|
+
"import": "./truncate-left.js"
|
|
166
|
+
},
|
|
167
|
+
"./truncate": {
|
|
168
|
+
"import": "./truncate.js"
|
|
169
|
+
},
|
|
170
|
+
"./units": {
|
|
171
|
+
"import": "./units.js"
|
|
172
|
+
},
|
|
173
|
+
"./uuid": {
|
|
174
|
+
"import": "./uuid.js"
|
|
175
|
+
},
|
|
176
|
+
"./vector": {
|
|
177
|
+
"import": "./vector.js"
|
|
178
|
+
},
|
|
179
|
+
"./word-wrap": {
|
|
180
|
+
"import": "./word-wrap.js"
|
|
181
|
+
},
|
|
182
|
+
"./wrap": {
|
|
183
|
+
"import": "./wrap.js"
|
|
184
|
+
}
|
|
185
|
+
},
|
|
79
186
|
"thi.ng": {
|
|
80
187
|
"year": 2015
|
|
81
188
|
},
|
|
82
|
-
"gitHead": "
|
|
189
|
+
"gitHead": "9ac1344b38b565eb894306fbf72233b6c0b2d115"
|
|
83
190
|
}
|
package/pad-left.js
CHANGED
package/pad-right.js
CHANGED
package/radix.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { U16 as $16, U24 as $24, U32 as $32, U64HL, U8 as $8, } from "@thi.ng/hex";
|
|
2
|
-
import { memoizeJ } from "@thi.ng/memoize";
|
|
2
|
+
import { memoizeJ } from "@thi.ng/memoize/memoizej";
|
|
3
3
|
import { repeat } from "./repeat";
|
|
4
4
|
/**
|
|
5
5
|
* Returns a {@link Stringer} which formats given numbers to `radix`, `len` and
|
package/repeat.js
CHANGED
package/splice.js
CHANGED
package/trim.js
CHANGED
package/truncate-left.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import { memoizeJ } from "@thi.ng/memoize";
|
|
2
|
-
export const truncateLeft = memoizeJ((n, prefix = "") => (x) => x.length > n
|
|
1
|
+
import { memoizeJ } from "@thi.ng/memoize/memoizej";
|
|
2
|
+
export const truncateLeft = memoizeJ((n, prefix = "") => (x) => x.length > n
|
|
3
|
+
? prefix + x.substr(x.length - n + prefix.length)
|
|
4
|
+
: x);
|
package/truncate.js
CHANGED
package/units.js
CHANGED
package/vector.js
CHANGED
package/word-wrap.js
CHANGED
|
@@ -8,9 +8,9 @@ import { split } from "./split";
|
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
10
|
class Line {
|
|
11
|
+
n = 0;
|
|
12
|
+
w = [];
|
|
11
13
|
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) {
|
|
@@ -114,7 +114,13 @@ export const wordWrapLine = (line, opts, acc = []) => {
|
|
|
114
114
|
acc.push(new Line());
|
|
115
115
|
return acc;
|
|
116
116
|
}
|
|
117
|
-
const $opts =
|
|
117
|
+
const $opts = {
|
|
118
|
+
width: 80,
|
|
119
|
+
min: 4,
|
|
120
|
+
hard: false,
|
|
121
|
+
splitter: SPLIT_PLAIN,
|
|
122
|
+
...opts,
|
|
123
|
+
};
|
|
118
124
|
for (let word of split(line, opts.delimWord || /\s/g)) {
|
|
119
125
|
const curr = acc[acc.length - 1];
|
|
120
126
|
wrapWord(word, $opts, curr && curr.n > 0 ? curr.n + 1 : 0, acc);
|
package/wrap.js
CHANGED