@thi.ng/strings 3.7.30 → 3.7.31
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/center.js +15 -10
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-04-
|
|
3
|
+
- **Last updated**: 2024-04-20T14:42:45Z
|
|
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.7.31](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.7.31) (2024-04-20)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- update type usage ([4664361](https://github.com/thi-ng/umbrella/commit/4664361))
|
|
17
|
+
|
|
12
18
|
### [3.7.28](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.7.28) (2024-03-27)
|
|
13
19
|
|
|
14
20
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -140,10 +140,10 @@ import * as str from "@thi.ng/strings";
|
|
|
140
140
|
Browser ESM import:
|
|
141
141
|
|
|
142
142
|
```html
|
|
143
|
-
<script type="module" src="https://
|
|
143
|
+
<script type="module" src="https://esm.run/@thi.ng/strings"></script>
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
[
|
|
146
|
+
[JSDelivr documentation](https://www.jsdelivr.com/)
|
|
147
147
|
|
|
148
148
|
For Node.js REPL:
|
|
149
149
|
|
package/center.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { memoizeJ } from "@thi.ng/memoize/memoizej";
|
|
2
2
|
import { repeat } from "./repeat.js";
|
|
3
3
|
import { truncate } from "./truncate.js";
|
|
4
|
-
const center = memoizeJ(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
const center = memoizeJ(
|
|
5
|
+
(n, pad = " ") => {
|
|
6
|
+
const buf = repeat(String(pad), n);
|
|
7
|
+
return (x) => {
|
|
8
|
+
if (x == null)
|
|
9
|
+
return buf;
|
|
10
|
+
x = x.toString();
|
|
11
|
+
const r = (n - x.length) / 2;
|
|
12
|
+
return x.length < n ? buf.substring(0, r) + x + buf.substring(
|
|
13
|
+
0,
|
|
14
|
+
r + ((n & 1) === (x.length & 1) ? 0 : 1)
|
|
15
|
+
) : truncate(n)(x);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
);
|
|
14
19
|
export {
|
|
15
20
|
center
|
|
16
21
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/strings",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.31",
|
|
4
4
|
"description": "Various string formatting & utility functions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.
|
|
40
|
-
"@thi.ng/errors": "^2.5.
|
|
41
|
-
"@thi.ng/hex": "^2.3.
|
|
42
|
-
"@thi.ng/memoize": "^3.3.
|
|
39
|
+
"@thi.ng/api": "^8.11.0",
|
|
40
|
+
"@thi.ng/errors": "^2.5.5",
|
|
41
|
+
"@thi.ng/hex": "^2.3.44",
|
|
42
|
+
"@thi.ng/memoize": "^3.3.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@microsoft/api-extractor": "^7.43.0",
|
|
@@ -204,5 +204,5 @@
|
|
|
204
204
|
"thi.ng": {
|
|
205
205
|
"year": 2015
|
|
206
206
|
},
|
|
207
|
-
"gitHead": "
|
|
207
|
+
"gitHead": "8339d05ecc857e529c7325a9839c0063b89e728d\n"
|
|
208
208
|
}
|