@thi.ng/strings 3.7.3 → 3.7.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**: 2023-12-11T10:07:09Z
3
+ - **Last updated**: 2023-12-19T11:01:47Z
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,13 @@ 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.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.7.4) (2023-12-18)
13
+
14
+ #### 🩹 Bug fixes
15
+
16
+ - improve split() regexp handling ([65fe14b](https://github.com/thi-ng/umbrella/commit/65fe14b))
17
+ - ensure given regexp has global flag enabled
18
+
12
19
  ## [3.7.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.7.0) (2023-11-24)
13
20
 
14
21
  #### 🚀 Features
package/README.md CHANGED
@@ -141,7 +141,7 @@ For Node.js REPL:
141
141
  const strings = await import("@thi.ng/strings");
142
142
  ```
143
143
 
144
- Package sizes (brotli'd, pre-treeshake): ESM: 5.41 KB
144
+ Package sizes (brotli'd, pre-treeshake): ESM: 5.43 KB
145
145
 
146
146
  ## Dependencies
147
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/strings",
3
- "version": "3.7.3",
3
+ "version": "3.7.5",
4
4
  "description": "Various string formatting & utility functions",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -35,16 +35,15 @@
35
35
  "test": "bun test"
36
36
  },
37
37
  "dependencies": {
38
- "@thi.ng/api": "^8.9.12",
39
- "@thi.ng/errors": "^2.4.6",
40
- "@thi.ng/hex": "^2.3.24",
41
- "@thi.ng/memoize": "^3.1.46"
38
+ "@thi.ng/api": "^8.9.14",
39
+ "@thi.ng/errors": "^2.4.8",
40
+ "@thi.ng/hex": "^2.3.26",
41
+ "@thi.ng/memoize": "^3.1.48"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@microsoft/api-extractor": "^7.38.3",
45
45
  "esbuild": "^0.19.8",
46
46
  "rimraf": "^5.0.5",
47
- "tools": "^0.0.1",
48
47
  "typedoc": "^0.25.4",
49
48
  "typescript": "^5.3.2"
50
49
  },
@@ -76,7 +75,7 @@
76
75
  "access": "public"
77
76
  },
78
77
  "engines": {
79
- "node": ">=12.7"
78
+ "node": ">=18"
80
79
  },
81
80
  "files": [
82
81
  "./*.js",
@@ -204,5 +203,5 @@
204
203
  "thi.ng": {
205
204
  "year": 2015
206
205
  },
207
- "gitHead": "5e7bafedfc3d53bc131469a28de31dd8e5b4a3ff\n"
206
+ "gitHead": "0d9265be7be13eccf0ef75eaedbfd42626339279\n"
208
207
  }
package/split.d.ts CHANGED
@@ -8,6 +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
+ * If given an regexp as `delim`, the function ensures the regexp has its global
12
+ * flag enabled.
13
+ *
11
14
  * @param src -
12
15
  * @param delim -
13
16
  * @param includeDelim -
package/split.js CHANGED
@@ -2,7 +2,14 @@ function* split(src, delim = /\r?\n/g, includeDelim = false) {
2
2
  let i = 0;
3
3
  const n = src.length;
4
4
  const include = ~~includeDelim;
5
- const re = typeof delim === "string" ? new RegExp(delim, "g") : delim;
5
+ let re;
6
+ if (typeof delim === "string") {
7
+ re = new RegExp(delim, "g");
8
+ } else if (!delim.flags.includes("g")) {
9
+ re = new RegExp(delim, delim.flags + "g");
10
+ } else {
11
+ re = delim;
12
+ }
6
13
  for (; i < n; ) {
7
14
  const m = re.exec(src);
8
15
  if (!m) {