@thi.ng/strings 3.3.2 → 3.3.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2022-03-11T12:13:49Z
3
+ - **Last updated**: 2022-06-09T16:14:01Z
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.63 KB
146
+ Package sizes (gzipped, pre-treeshake): ESM: 4.64 KB
147
147
 
148
148
  ## Dependencies
149
149
 
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.substr(1);
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.substr(0, r) +
31
+ ? buf.substring(0, r) +
32
32
  x +
33
- buf.substr(0, r + ((n & 1) === (x.length & 1) ? 0 : 1))
33
+ buf.substring(0, r + ((n & 1) === (x.length & 1) ? 0 : 1))
34
34
  : truncate(n)(x);
35
35
  };
36
36
  });
package/currency.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Stringer } from "./api.js";
2
- export declare const currency: (sym: string, pre?: boolean | undefined, prec?: number | undefined) => Stringer<number>;
2
+ export declare const currency: (sym: string, pre?: boolean, prec?: number) => Stringer<number>;
3
3
  export declare const chf: Stringer<number>;
4
4
  export declare const eur: Stringer<number>;
5
5
  export declare const gbp: Stringer<number>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/strings",
3
- "version": "3.3.2",
3
+ "version": "3.3.5",
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.4",
38
- "@thi.ng/errors": "^2.1.4",
39
- "@thi.ng/hex": "^2.1.4",
40
- "@thi.ng/memoize": "^3.1.4"
37
+ "@thi.ng/api": "^8.3.7",
38
+ "@thi.ng/errors": "^2.1.7",
39
+ "@thi.ng/hex": "^2.1.7",
40
+ "@thi.ng/memoize": "^3.1.7"
41
41
  },
42
42
  "devDependencies": {
43
- "@microsoft/api-extractor": "^7.19.4",
44
- "@thi.ng/testament": "^0.2.4",
43
+ "@microsoft/api-extractor": "^7.25.0",
44
+ "@thi.ng/testament": "^0.2.8",
45
45
  "rimraf": "^3.0.2",
46
46
  "tools": "^0.0.1",
47
- "typedoc": "^0.22.13",
48
- "typescript": "^4.6.2"
47
+ "typedoc": "^0.22.17",
48
+ "typescript": "^4.7.3"
49
49
  },
50
50
  "keywords": [
51
51
  "ansi",
@@ -83,122 +83,122 @@
83
83
  ],
84
84
  "exports": {
85
85
  ".": {
86
- "import": "./index.js"
86
+ "default": "./index.js"
87
87
  },
88
88
  "./ansi": {
89
- "import": "./ansi.js"
89
+ "default": "./ansi.js"
90
90
  },
91
91
  "./api": {
92
- "import": "./api.js"
92
+ "default": "./api.js"
93
93
  },
94
94
  "./case": {
95
- "import": "./case.js"
95
+ "default": "./case.js"
96
96
  },
97
97
  "./center": {
98
- "import": "./center.js"
98
+ "default": "./center.js"
99
99
  },
100
100
  "./currency": {
101
- "import": "./currency.js"
101
+ "default": "./currency.js"
102
102
  },
103
103
  "./cursor": {
104
- "import": "./cursor.js"
104
+ "default": "./cursor.js"
105
105
  },
106
106
  "./entities": {
107
- "import": "./entities.js"
107
+ "default": "./entities.js"
108
108
  },
109
109
  "./escape": {
110
- "import": "./escape.js"
110
+ "default": "./escape.js"
111
111
  },
112
112
  "./float": {
113
- "import": "./float.js"
113
+ "default": "./float.js"
114
114
  },
115
115
  "./format": {
116
- "import": "./format.js"
116
+ "default": "./format.js"
117
117
  },
118
118
  "./groups": {
119
- "import": "./groups.js"
119
+ "default": "./groups.js"
120
120
  },
121
121
  "./hollerith": {
122
- "import": "./hollerith.js"
122
+ "default": "./hollerith.js"
123
123
  },
124
124
  "./initials": {
125
- "import": "./initials.js"
125
+ "default": "./initials.js"
126
126
  },
127
127
  "./int": {
128
- "import": "./int.js"
128
+ "default": "./int.js"
129
129
  },
130
130
  "./interpolate": {
131
- "import": "./interpolate.js"
131
+ "default": "./interpolate.js"
132
132
  },
133
133
  "./join": {
134
- "import": "./join.js"
134
+ "default": "./join.js"
135
135
  },
136
136
  "./pad-left": {
137
- "import": "./pad-left.js"
137
+ "default": "./pad-left.js"
138
138
  },
139
139
  "./pad-right": {
140
- "import": "./pad-right.js"
140
+ "default": "./pad-right.js"
141
141
  },
142
142
  "./parse": {
143
- "import": "./parse.js"
143
+ "default": "./parse.js"
144
144
  },
145
145
  "./percent": {
146
- "import": "./percent.js"
146
+ "default": "./percent.js"
147
147
  },
148
148
  "./radix": {
149
- "import": "./radix.js"
149
+ "default": "./radix.js"
150
150
  },
151
151
  "./range": {
152
- "import": "./range.js"
152
+ "default": "./range.js"
153
153
  },
154
154
  "./repeat": {
155
- "import": "./repeat.js"
155
+ "default": "./repeat.js"
156
156
  },
157
157
  "./ruler": {
158
- "import": "./ruler.js"
158
+ "default": "./ruler.js"
159
159
  },
160
160
  "./slugify": {
161
- "import": "./slugify.js"
161
+ "default": "./slugify.js"
162
162
  },
163
163
  "./splice": {
164
- "import": "./splice.js"
164
+ "default": "./splice.js"
165
165
  },
166
166
  "./split": {
167
- "import": "./split.js"
167
+ "default": "./split.js"
168
168
  },
169
169
  "./stringify": {
170
- "import": "./stringify.js"
170
+ "default": "./stringify.js"
171
171
  },
172
172
  "./tabs": {
173
- "import": "./tabs.js"
173
+ "default": "./tabs.js"
174
174
  },
175
175
  "./trim": {
176
- "import": "./trim.js"
176
+ "default": "./trim.js"
177
177
  },
178
178
  "./truncate-left": {
179
- "import": "./truncate-left.js"
179
+ "default": "./truncate-left.js"
180
180
  },
181
181
  "./truncate": {
182
- "import": "./truncate.js"
182
+ "default": "./truncate.js"
183
183
  },
184
184
  "./units": {
185
- "import": "./units.js"
185
+ "default": "./units.js"
186
186
  },
187
187
  "./uuid": {
188
- "import": "./uuid.js"
188
+ "default": "./uuid.js"
189
189
  },
190
190
  "./vector": {
191
- "import": "./vector.js"
191
+ "default": "./vector.js"
192
192
  },
193
193
  "./word-wrap": {
194
- "import": "./word-wrap.js"
194
+ "default": "./word-wrap.js"
195
195
  },
196
196
  "./wrap": {
197
- "import": "./wrap.js"
197
+ "default": "./wrap.js"
198
198
  }
199
199
  },
200
200
  "thi.ng": {
201
201
  "year": 2015
202
202
  },
203
- "gitHead": "0fc692a3225c068aacafdc4cb6140cf603c67ad8\n"
203
+ "gitHead": "9e516d30a1a537e027a6b3d78bf9121bc5831d31\n"
204
204
  }
package/pad-left.d.ts CHANGED
@@ -6,13 +6,13 @@ export declare const padLeft: (n: number, ch?: string | number) => (x: any, leng
6
6
  /**
7
7
  * Zero-padded 2 digit formatter.
8
8
  */
9
- export declare const Z2: (x: any, length?: number | undefined) => string;
9
+ export declare const Z2: (x: any, length?: number) => string;
10
10
  /**
11
11
  * Zero-padded 3 digit formatter.
12
12
  */
13
- export declare const Z3: (x: any, length?: number | undefined) => string;
13
+ export declare const Z3: (x: any, length?: number) => string;
14
14
  /**
15
15
  * Zero-padded 4 digit formatter.
16
16
  */
17
- export declare const Z4: (x: any, length?: number | undefined) => string;
17
+ export declare const Z4: (x: any, length?: number) => string;
18
18
  //# sourceMappingURL=pad-left.d.ts.map
package/pad-left.js CHANGED
@@ -11,7 +11,7 @@ export const padLeft = memoizeJ((n, ch = " ") => {
11
11
  return buf;
12
12
  x = x.toString();
13
13
  len = len !== undefined ? len : x.length;
14
- return len < n ? buf.substr(len) + x : x;
14
+ return len < n ? buf.substring(len) + x : x;
15
15
  };
16
16
  });
17
17
  /**
package/pad-right.js CHANGED
@@ -11,6 +11,6 @@ export const padRight = memoizeJ((n, ch = " ") => {
11
11
  return buf;
12
12
  x = x.toString();
13
13
  len = len !== undefined ? len : x.length;
14
- return len < n ? x + buf.substr(len) : x;
14
+ return len < n ? x + buf.substring(len) : x;
15
15
  };
16
16
  });
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.substr(x.length) + x : x);
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)).substr(0, width);
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.substr(to)
27
+ ? insert + src.substring(to)
28
28
  : from >= src.length
29
29
  ? src + insert
30
- : src.substr(0, from) + insert + src.substr(to);
30
+ : src.substring(0, from) + insert + src.substring(to);
31
31
  };
package/stringify.d.ts CHANGED
@@ -8,5 +8,5 @@ import type { Stringer } from "./api.js";
8
8
  * @param all -
9
9
  * @param indent -
10
10
  */
11
- export declare const stringify: (all?: boolean, indent?: number | undefined) => Stringer<any>;
11
+ export declare const stringify: (all?: boolean, indent?: number) => Stringer<any>;
12
12
  //# sourceMappingURL=stringify.d.ts.map
package/tabs.js CHANGED
@@ -83,5 +83,5 @@ export const spacesToTabsLine = (line, tabSize = 4) => {
83
83
  }
84
84
  i = end;
85
85
  }
86
- return res + line.substr(i);
86
+ return res + line.substring(i);
87
87
  };
package/truncate-left.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { memoizeJ } from "@thi.ng/memoize/memoizej";
2
2
  export const truncateLeft = memoizeJ((n, prefix = "") => (x) => x.length > n
3
- ? prefix + x.substr(x.length - n + prefix.length)
3
+ ? prefix + x.substring(x.length - n + prefix.length)
4
4
  : x);
package/truncate.d.ts CHANGED
@@ -3,5 +3,5 @@ export declare const truncate: (n: number, suffix?: string) => Stringer<string>;
3
3
  /**
4
4
  * Alias for {@link truncate}
5
5
  */
6
- export declare const truncateRight: (n: number, suffix?: string | undefined) => Stringer<string>;
6
+ export declare const truncateRight: (n: number, suffix?: string) => Stringer<string>;
7
7
  //# sourceMappingURL=truncate.d.ts.map
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.substr(0, n - suffix.length) + suffix : 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.substr(0, split);
90
+ const chunk = word.substring(0, split);
91
91
  append(acc, chunk, free, width);
92
- word = word.substr(split);
92
+ word = word.substring(split);
93
93
  free = width;
94
94
  len = splitter.length(word);
95
95
  }