@ls-stack/utils 3.61.0 → 3.63.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.
@@ -31,6 +31,7 @@ __export(arrayUtils_exports, {
31
31
  hasDuplicates: () => hasDuplicates,
32
32
  intersperse: () => intersperse,
33
33
  isInArray: () => isInArray,
34
+ isInArrayWithoutNarrowing: () => isInArrayWithoutNarrowing,
34
35
  looseIsInArray: () => looseIsInArray,
35
36
  rejectArrayUndefinedValues: () => rejectArrayUndefinedValues,
36
37
  rejectDuplicates: () => rejectDuplicates,
@@ -106,6 +107,9 @@ function isInArray(value, oneOf) {
106
107
  }
107
108
  return false;
108
109
  }
110
+ function isInArrayWithoutNarrowing(value, oneOf) {
111
+ return oneOf.includes(value);
112
+ }
109
113
  function looseIsInArray(value, array) {
110
114
  return array.includes(value);
111
115
  }
@@ -215,6 +219,7 @@ function repeat(value, count, separator) {
215
219
  hasDuplicates,
216
220
  intersperse,
217
221
  isInArray,
222
+ isInArrayWithoutNarrowing,
218
223
  looseIsInArray,
219
224
  rejectArrayUndefinedValues,
220
225
  rejectDuplicates,
@@ -76,6 +76,7 @@ declare function arrayWithPrevAndIndex<T>(array: T[]): {
76
76
  index: number;
77
77
  }[];
78
78
  declare function isInArray<T, const U extends T>(value: T, oneOf: readonly U[]): value is U;
79
+ declare function isInArrayWithoutNarrowing<T, const U extends T>(value: T, oneOf: readonly U[]): boolean;
79
80
  declare function looseIsInArray(value: unknown, array: readonly unknown[]): boolean;
80
81
  declare function findAfterIndex<T>(array: T[], index: number, predicate: (item: T) => boolean): T | undefined;
81
82
  declare function findBeforeIndex<T>(array: T[], index: number, predicate: (item: T) => boolean): T | undefined;
@@ -167,4 +168,4 @@ declare function intersperse<T, I>(array: T[], separator: I): (T | I)[];
167
168
  */
168
169
  declare function repeat<T>(value: T, count: number, separator?: T): T[];
169
170
 
170
- export { type FilterAndMapReturn, type SortByProps, type SortByValueFn, arrayOps, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findAndMap, findBeforeIndex, getAscIndexOrder, hasDuplicates, intersperse, isInArray, looseIsInArray, rejectArrayUndefinedValues, rejectDuplicates, repeat, sortBy, truncateArray };
171
+ export { type FilterAndMapReturn, type SortByProps, type SortByValueFn, arrayOps, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findAndMap, findBeforeIndex, getAscIndexOrder, hasDuplicates, intersperse, isInArray, isInArrayWithoutNarrowing, looseIsInArray, rejectArrayUndefinedValues, rejectDuplicates, repeat, sortBy, truncateArray };
@@ -76,6 +76,7 @@ declare function arrayWithPrevAndIndex<T>(array: T[]): {
76
76
  index: number;
77
77
  }[];
78
78
  declare function isInArray<T, const U extends T>(value: T, oneOf: readonly U[]): value is U;
79
+ declare function isInArrayWithoutNarrowing<T, const U extends T>(value: T, oneOf: readonly U[]): boolean;
79
80
  declare function looseIsInArray(value: unknown, array: readonly unknown[]): boolean;
80
81
  declare function findAfterIndex<T>(array: T[], index: number, predicate: (item: T) => boolean): T | undefined;
81
82
  declare function findBeforeIndex<T>(array: T[], index: number, predicate: (item: T) => boolean): T | undefined;
@@ -167,4 +168,4 @@ declare function intersperse<T, I>(array: T[], separator: I): (T | I)[];
167
168
  */
168
169
  declare function repeat<T>(value: T, count: number, separator?: T): T[];
169
170
 
170
- export { type FilterAndMapReturn, type SortByProps, type SortByValueFn, arrayOps, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findAndMap, findBeforeIndex, getAscIndexOrder, hasDuplicates, intersperse, isInArray, looseIsInArray, rejectArrayUndefinedValues, rejectDuplicates, repeat, sortBy, truncateArray };
171
+ export { type FilterAndMapReturn, type SortByProps, type SortByValueFn, arrayOps, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findAndMap, findBeforeIndex, getAscIndexOrder, hasDuplicates, intersperse, isInArray, isInArrayWithoutNarrowing, looseIsInArray, rejectArrayUndefinedValues, rejectDuplicates, repeat, sortBy, truncateArray };
@@ -10,13 +10,14 @@ import {
10
10
  hasDuplicates,
11
11
  intersperse,
12
12
  isInArray,
13
+ isInArrayWithoutNarrowing,
13
14
  looseIsInArray,
14
15
  rejectArrayUndefinedValues,
15
16
  rejectDuplicates,
16
17
  repeat,
17
18
  sortBy,
18
19
  truncateArray
19
- } from "./chunk-GVIDV772.js";
20
+ } from "./chunk-WFQJUJTC.js";
20
21
  import "./chunk-C2SVCIWE.js";
21
22
  import "./chunk-JF2MDHOJ.js";
22
23
  export {
@@ -31,6 +32,7 @@ export {
31
32
  hasDuplicates,
32
33
  intersperse,
33
34
  isInArray,
35
+ isInArrayWithoutNarrowing,
34
36
  looseIsInArray,
35
37
  rejectArrayUndefinedValues,
36
38
  rejectDuplicates,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sortBy
3
- } from "./chunk-GVIDV772.js";
3
+ } from "./chunk-WFQJUJTC.js";
4
4
  import {
5
5
  isPlainObject
6
6
  } from "./chunk-JF2MDHOJ.js";
@@ -60,6 +60,9 @@ function isInArray(value, oneOf) {
60
60
  }
61
61
  return false;
62
62
  }
63
+ function isInArrayWithoutNarrowing(value, oneOf) {
64
+ return oneOf.includes(value);
65
+ }
63
66
  function looseIsInArray(value, array) {
64
67
  return array.includes(value);
65
68
  }
@@ -164,6 +167,7 @@ export {
164
167
  arrayWithPrev,
165
168
  arrayWithPrevAndIndex,
166
169
  isInArray,
170
+ isInArrayWithoutNarrowing,
167
171
  looseIsInArray,
168
172
  findAfterIndex,
169
173
  findBeforeIndex,
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-GMJTLFM6.js";
4
4
  import {
5
5
  sortBy
6
- } from "./chunk-GVIDV772.js";
6
+ } from "./chunk-WFQJUJTC.js";
7
7
 
8
8
  // src/objUtils.ts
9
9
  import { Result } from "t-result";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-5DZT3Z5Z.js";
10
10
  import {
11
11
  truncateArray
12
- } from "./chunk-GVIDV772.js";
12
+ } from "./chunk-WFQJUJTC.js";
13
13
  import {
14
14
  invariant
15
15
  } from "./chunk-C2SVCIWE.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  filterObjectOrArrayKeys
3
- } from "./chunk-2LO5FYP5.js";
4
- import "./chunk-GVIDV772.js";
3
+ } from "./chunk-MI4UE2PQ.js";
4
+ import "./chunk-WFQJUJTC.js";
5
5
  import "./chunk-C2SVCIWE.js";
6
6
  import "./chunk-JF2MDHOJ.js";
7
7
  export {
package/dist/objUtils.js CHANGED
@@ -14,9 +14,9 @@ import {
14
14
  pick,
15
15
  rejectObjUndefinedValues,
16
16
  sortObjectKeys
17
- } from "./chunk-SGRS4OEE.js";
17
+ } from "./chunk-ZXIKIA5B.js";
18
18
  import "./chunk-GMJTLFM6.js";
19
- import "./chunk-GVIDV772.js";
19
+ import "./chunk-WFQJUJTC.js";
20
20
  import "./chunk-C2SVCIWE.js";
21
21
  import "./chunk-JF2MDHOJ.js";
22
22
  export {
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/regexUtils.ts
21
+ var regexUtils_exports = {};
22
+ __export(regexUtils_exports, {
23
+ escapeRegExp: () => escapeRegExp,
24
+ getRegexMatchAll: () => getRegexMatchAll,
25
+ getRegexMatches: () => getRegexMatches
26
+ });
27
+ module.exports = __toCommonJS(regexUtils_exports);
28
+ function getRegexMatches(string, regex) {
29
+ const [fullMatch, ...groups] = regex.exec(string) || [void 0];
30
+ return { groups, fullMatch };
31
+ }
32
+ function* getRegexMatchAll(str, regexp) {
33
+ const flags = regexp.global ? regexp.flags : `${regexp.flags}g`;
34
+ const re = new RegExp(regexp, flags);
35
+ let match;
36
+ let lastIndex = 0;
37
+ while (match = re.exec(str)) {
38
+ const [fullMatch, ...groups] = match;
39
+ const prevLastIndex = lastIndex;
40
+ lastIndex = re.lastIndex;
41
+ yield {
42
+ groups,
43
+ fullMatch,
44
+ namedGroups: match.groups,
45
+ start: match.index,
46
+ end: lastIndex,
47
+ prevEnd: prevLastIndex
48
+ };
49
+ }
50
+ }
51
+ var SPECIAL_REGEX_CHARS = /[.*+?^${}()|[\]\\]/g;
52
+ function escapeRegExp(value) {
53
+ return value.replace(SPECIAL_REGEX_CHARS, "\\$&");
54
+ }
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ escapeRegExp,
58
+ getRegexMatchAll,
59
+ getRegexMatches
60
+ });
@@ -0,0 +1,17 @@
1
+ declare function getRegexMatches(string: string, regex: RegExp): {
2
+ groups: (string | undefined)[];
3
+ fullMatch: string | undefined;
4
+ };
5
+ declare function getRegexMatchAll(str: string, regexp: RegExp): Generator<{
6
+ groups: (string | undefined)[];
7
+ fullMatch: string;
8
+ namedGroups: {
9
+ [key: string]: string;
10
+ } | undefined;
11
+ start: number;
12
+ end: number;
13
+ prevEnd: number;
14
+ }, void, unknown>;
15
+ declare function escapeRegExp(value: string): string;
16
+
17
+ export { escapeRegExp, getRegexMatchAll, getRegexMatches };
@@ -0,0 +1,17 @@
1
+ declare function getRegexMatches(string: string, regex: RegExp): {
2
+ groups: (string | undefined)[];
3
+ fullMatch: string | undefined;
4
+ };
5
+ declare function getRegexMatchAll(str: string, regexp: RegExp): Generator<{
6
+ groups: (string | undefined)[];
7
+ fullMatch: string;
8
+ namedGroups: {
9
+ [key: string]: string;
10
+ } | undefined;
11
+ start: number;
12
+ end: number;
13
+ prevEnd: number;
14
+ }, void, unknown>;
15
+ declare function escapeRegExp(value: string): string;
16
+
17
+ export { escapeRegExp, getRegexMatchAll, getRegexMatches };
@@ -0,0 +1,33 @@
1
+ // src/regexUtils.ts
2
+ function getRegexMatches(string, regex) {
3
+ const [fullMatch, ...groups] = regex.exec(string) || [void 0];
4
+ return { groups, fullMatch };
5
+ }
6
+ function* getRegexMatchAll(str, regexp) {
7
+ const flags = regexp.global ? regexp.flags : `${regexp.flags}g`;
8
+ const re = new RegExp(regexp, flags);
9
+ let match;
10
+ let lastIndex = 0;
11
+ while (match = re.exec(str)) {
12
+ const [fullMatch, ...groups] = match;
13
+ const prevLastIndex = lastIndex;
14
+ lastIndex = re.lastIndex;
15
+ yield {
16
+ groups,
17
+ fullMatch,
18
+ namedGroups: match.groups,
19
+ start: match.index,
20
+ end: lastIndex,
21
+ prevEnd: prevLastIndex
22
+ };
23
+ }
24
+ }
25
+ var SPECIAL_REGEX_CHARS = /[.*+?^${}()|[\]\\]/g;
26
+ function escapeRegExp(value) {
27
+ return value.replace(SPECIAL_REGEX_CHARS, "\\$&");
28
+ }
29
+ export {
30
+ escapeRegExp,
31
+ getRegexMatchAll,
32
+ getRegexMatches
33
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  filterAndMap
3
- } from "./chunk-GVIDV772.js";
3
+ } from "./chunk-WFQJUJTC.js";
4
4
  import "./chunk-C2SVCIWE.js";
5
5
  import {
6
6
  isTruthy
package/dist/testUtils.js CHANGED
@@ -4,11 +4,11 @@ import {
4
4
  import {
5
5
  omit,
6
6
  pick
7
- } from "./chunk-SGRS4OEE.js";
7
+ } from "./chunk-ZXIKIA5B.js";
8
8
  import "./chunk-GMJTLFM6.js";
9
9
  import {
10
10
  filterObjectOrArrayKeys
11
- } from "./chunk-2LO5FYP5.js";
11
+ } from "./chunk-MI4UE2PQ.js";
12
12
  import "./chunk-IATIXMCE.js";
13
13
  import {
14
14
  deepEqual
@@ -26,7 +26,7 @@ import "./chunk-BM4PYVOX.js";
26
26
  import {
27
27
  arrayWithPrevAndIndex,
28
28
  filterAndMap
29
- } from "./chunk-GVIDV772.js";
29
+ } from "./chunk-WFQJUJTC.js";
30
30
  import {
31
31
  isObject
32
32
  } from "./chunk-C2SVCIWE.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ls-stack/utils",
3
3
  "description": "Universal TypeScript utilities for browser and Node.js",
4
- "version": "3.61.0",
4
+ "version": "3.63.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "dist",
@@ -152,6 +152,10 @@
152
152
  "import": "./dist/promiseUtils.js",
153
153
  "require": "./dist/promiseUtils.cjs"
154
154
  },
155
+ "./regexUtils": {
156
+ "import": "./dist/regexUtils.js",
157
+ "require": "./dist/regexUtils.cjs"
158
+ },
155
159
  "./retryOnError": {
156
160
  "import": "./dist/retryOnError.js",
157
161
  "require": "./dist/retryOnError.cjs"