@thi.ng/strings 3.3.2 → 3.3.3
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/case.js +1 -1
- package/center.js +2 -2
- package/package.json +45 -45
- package/pad-left.js +1 -1
- package/pad-right.js +1 -1
- package/radix.js +1 -1
- package/ruler.js +1 -1
- package/splice.js +2 -2
- package/tabs.js +1 -1
- package/truncate-left.js +1 -1
- package/truncate.js +1 -1
- package/word-wrap.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2022-
|
|
3
|
+
- **Last updated**: 2022-04-07T14:17:30Z
|
|
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/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).
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/strings",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.3",
|
|
4
4
|
"description": "Various string formatting & utility functions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,14 +34,14 @@
|
|
|
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.5",
|
|
38
|
+
"@thi.ng/errors": "^2.1.5",
|
|
39
|
+
"@thi.ng/hex": "^2.1.5",
|
|
40
|
+
"@thi.ng/memoize": "^3.1.5"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@microsoft/api-extractor": "^7.19.4",
|
|
44
|
-
"@thi.ng/testament": "^0.2.
|
|
44
|
+
"@thi.ng/testament": "^0.2.5",
|
|
45
45
|
"rimraf": "^3.0.2",
|
|
46
46
|
"tools": "^0.0.1",
|
|
47
47
|
"typedoc": "^0.22.13",
|
|
@@ -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": "5ee1feb590dd935593b1dd4e7f38a3ed3ba64765\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.js
CHANGED
|
@@ -17,7 +17,7 @@ import { repeat } from "./repeat.js";
|
|
|
17
17
|
* @param a -
|
|
18
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.
|
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/tabs.js
CHANGED
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.js
CHANGED
|
@@ -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
|
}
|