@ls-stack/utils 3.3.2 → 3.4.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.
- package/lib/arrayUtils.cjs +5 -0
- package/lib/arrayUtils.d.cts +2 -1
- package/lib/arrayUtils.d.ts +2 -1
- package/lib/arrayUtils.js +3 -1
- package/lib/{chunk-QMFZE2VO.js → chunk-5JQGMNNY.js} +5 -1
- package/lib/{chunk-ZE3DLPMN.js → chunk-MWND73GM.js} +11 -1
- package/lib/objUtils.cjs +13 -2
- package/lib/objUtils.d.cts +2 -1
- package/lib/objUtils.d.ts +2 -1
- package/lib/objUtils.js +5 -3
- package/lib/testUtils.js +2 -2
- package/package.json +1 -1
package/lib/arrayUtils.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(arrayUtils_exports, {
|
|
|
26
26
|
findAfterIndex: () => findAfterIndex,
|
|
27
27
|
findBeforeIndex: () => findBeforeIndex,
|
|
28
28
|
isInArray: () => isInArray,
|
|
29
|
+
rejectArrayUndefinedValues: () => rejectArrayUndefinedValues,
|
|
29
30
|
sortBy: () => sortBy
|
|
30
31
|
});
|
|
31
32
|
module.exports = __toCommonJS(arrayUtils_exports);
|
|
@@ -103,6 +104,9 @@ function findBeforeIndex(array, index, predicate) {
|
|
|
103
104
|
}
|
|
104
105
|
return void 0;
|
|
105
106
|
}
|
|
107
|
+
function rejectArrayUndefinedValues(array) {
|
|
108
|
+
return array.filter((item) => item !== void 0);
|
|
109
|
+
}
|
|
106
110
|
// Annotate the CommonJS export names for ESM import in node:
|
|
107
111
|
0 && (module.exports = {
|
|
108
112
|
arrayWithPrev,
|
|
@@ -111,5 +115,6 @@ function findBeforeIndex(array, index, predicate) {
|
|
|
111
115
|
findAfterIndex,
|
|
112
116
|
findBeforeIndex,
|
|
113
117
|
isInArray,
|
|
118
|
+
rejectArrayUndefinedValues,
|
|
114
119
|
sortBy
|
|
115
120
|
});
|
package/lib/arrayUtils.d.cts
CHANGED
|
@@ -49,5 +49,6 @@ declare function arrayWithPrevAndIndex<T>(array: T[]): {
|
|
|
49
49
|
declare function isInArray<T, const U extends T>(value: T, oneOf: readonly U[]): value is U;
|
|
50
50
|
declare function findAfterIndex<T>(array: T[], index: number, predicate: (item: T) => boolean): T | undefined;
|
|
51
51
|
declare function findBeforeIndex<T>(array: T[], index: number, predicate: (item: T) => boolean): T | undefined;
|
|
52
|
+
declare function rejectArrayUndefinedValues<T extends unknown[]>(array: T): T;
|
|
52
53
|
|
|
53
|
-
export { type FilterAndMapReturn, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findBeforeIndex, isInArray, sortBy };
|
|
54
|
+
export { type FilterAndMapReturn, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findBeforeIndex, isInArray, rejectArrayUndefinedValues, sortBy };
|
package/lib/arrayUtils.d.ts
CHANGED
|
@@ -49,5 +49,6 @@ declare function arrayWithPrevAndIndex<T>(array: T[]): {
|
|
|
49
49
|
declare function isInArray<T, const U extends T>(value: T, oneOf: readonly U[]): value is U;
|
|
50
50
|
declare function findAfterIndex<T>(array: T[], index: number, predicate: (item: T) => boolean): T | undefined;
|
|
51
51
|
declare function findBeforeIndex<T>(array: T[], index: number, predicate: (item: T) => boolean): T | undefined;
|
|
52
|
+
declare function rejectArrayUndefinedValues<T extends unknown[]>(array: T): T;
|
|
52
53
|
|
|
53
|
-
export { type FilterAndMapReturn, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findBeforeIndex, isInArray, sortBy };
|
|
54
|
+
export { type FilterAndMapReturn, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findBeforeIndex, isInArray, rejectArrayUndefinedValues, sortBy };
|
package/lib/arrayUtils.js
CHANGED
|
@@ -5,8 +5,9 @@ import {
|
|
|
5
5
|
findAfterIndex,
|
|
6
6
|
findBeforeIndex,
|
|
7
7
|
isInArray,
|
|
8
|
+
rejectArrayUndefinedValues,
|
|
8
9
|
sortBy
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-5JQGMNNY.js";
|
|
10
11
|
export {
|
|
11
12
|
arrayWithPrev,
|
|
12
13
|
arrayWithPrevAndIndex,
|
|
@@ -14,5 +15,6 @@ export {
|
|
|
14
15
|
findAfterIndex,
|
|
15
16
|
findBeforeIndex,
|
|
16
17
|
isInArray,
|
|
18
|
+
rejectArrayUndefinedValues,
|
|
17
19
|
sortBy
|
|
18
20
|
};
|
|
@@ -73,6 +73,9 @@ function findBeforeIndex(array, index, predicate) {
|
|
|
73
73
|
}
|
|
74
74
|
return void 0;
|
|
75
75
|
}
|
|
76
|
+
function rejectArrayUndefinedValues(array) {
|
|
77
|
+
return array.filter((item) => item !== void 0);
|
|
78
|
+
}
|
|
76
79
|
|
|
77
80
|
export {
|
|
78
81
|
filterAndMap,
|
|
@@ -81,5 +84,6 @@ export {
|
|
|
81
84
|
arrayWithPrevAndIndex,
|
|
82
85
|
isInArray,
|
|
83
86
|
findAfterIndex,
|
|
84
|
-
findBeforeIndex
|
|
87
|
+
findBeforeIndex,
|
|
88
|
+
rejectArrayUndefinedValues
|
|
85
89
|
};
|
|
@@ -32,6 +32,15 @@ function omit(obj, keys) {
|
|
|
32
32
|
function looseGetObjectProperty(obj, key) {
|
|
33
33
|
return obj[key];
|
|
34
34
|
}
|
|
35
|
+
function rejectObjUndefinedValues(obj) {
|
|
36
|
+
const result = {};
|
|
37
|
+
for (const key in obj) {
|
|
38
|
+
if (obj[key] !== void 0) {
|
|
39
|
+
result[key] = obj[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
35
44
|
|
|
36
45
|
export {
|
|
37
46
|
objectTypedEntries,
|
|
@@ -39,5 +48,6 @@ export {
|
|
|
39
48
|
mapArrayToObject,
|
|
40
49
|
mapObjectToObject,
|
|
41
50
|
omit,
|
|
42
|
-
looseGetObjectProperty
|
|
51
|
+
looseGetObjectProperty,
|
|
52
|
+
rejectObjUndefinedValues
|
|
43
53
|
};
|
package/lib/objUtils.cjs
CHANGED
|
@@ -25,7 +25,8 @@ __export(objUtils_exports, {
|
|
|
25
25
|
mapObjectToObject: () => mapObjectToObject,
|
|
26
26
|
objectTypedEntries: () => objectTypedEntries,
|
|
27
27
|
omit: () => omit,
|
|
28
|
-
pick: () => pick
|
|
28
|
+
pick: () => pick,
|
|
29
|
+
rejectObjUndefinedValues: () => rejectObjUndefinedValues
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(objUtils_exports);
|
|
31
32
|
function objectTypedEntries(obj) {
|
|
@@ -61,6 +62,15 @@ function omit(obj, keys) {
|
|
|
61
62
|
function looseGetObjectProperty(obj, key) {
|
|
62
63
|
return obj[key];
|
|
63
64
|
}
|
|
65
|
+
function rejectObjUndefinedValues(obj) {
|
|
66
|
+
const result = {};
|
|
67
|
+
for (const key in obj) {
|
|
68
|
+
if (obj[key] !== void 0) {
|
|
69
|
+
result[key] = obj[key];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
64
74
|
// Annotate the CommonJS export names for ESM import in node:
|
|
65
75
|
0 && (module.exports = {
|
|
66
76
|
looseGetObjectProperty,
|
|
@@ -68,5 +78,6 @@ function looseGetObjectProperty(obj, key) {
|
|
|
68
78
|
mapObjectToObject,
|
|
69
79
|
objectTypedEntries,
|
|
70
80
|
omit,
|
|
71
|
-
pick
|
|
81
|
+
pick,
|
|
82
|
+
rejectObjUndefinedValues
|
|
72
83
|
});
|
package/lib/objUtils.d.cts
CHANGED
|
@@ -4,5 +4,6 @@ declare function mapArrayToObject<T, K extends string, O>(array: T[], mapper: (i
|
|
|
4
4
|
declare function mapObjectToObject<I extends Record<string | number | symbol, unknown>, K extends string | number | symbol, O>(obj: I, mapper: (key: keyof I, value: I[keyof I]) => [K, O]): Record<K, O>;
|
|
5
5
|
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
6
6
|
declare function looseGetObjectProperty<T extends Record<string, unknown>>(obj: T, key: string): T[keyof T] | undefined;
|
|
7
|
+
declare function rejectObjUndefinedValues<T extends Record<string, unknown>>(obj: T): T;
|
|
7
8
|
|
|
8
|
-
export { looseGetObjectProperty, mapArrayToObject, mapObjectToObject, objectTypedEntries, omit, pick };
|
|
9
|
+
export { looseGetObjectProperty, mapArrayToObject, mapObjectToObject, objectTypedEntries, omit, pick, rejectObjUndefinedValues };
|
package/lib/objUtils.d.ts
CHANGED
|
@@ -4,5 +4,6 @@ declare function mapArrayToObject<T, K extends string, O>(array: T[], mapper: (i
|
|
|
4
4
|
declare function mapObjectToObject<I extends Record<string | number | symbol, unknown>, K extends string | number | symbol, O>(obj: I, mapper: (key: keyof I, value: I[keyof I]) => [K, O]): Record<K, O>;
|
|
5
5
|
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
6
6
|
declare function looseGetObjectProperty<T extends Record<string, unknown>>(obj: T, key: string): T[keyof T] | undefined;
|
|
7
|
+
declare function rejectObjUndefinedValues<T extends Record<string, unknown>>(obj: T): T;
|
|
7
8
|
|
|
8
|
-
export { looseGetObjectProperty, mapArrayToObject, mapObjectToObject, objectTypedEntries, omit, pick };
|
|
9
|
+
export { looseGetObjectProperty, mapArrayToObject, mapObjectToObject, objectTypedEntries, omit, pick, rejectObjUndefinedValues };
|
package/lib/objUtils.js
CHANGED
|
@@ -4,13 +4,15 @@ import {
|
|
|
4
4
|
mapObjectToObject,
|
|
5
5
|
objectTypedEntries,
|
|
6
6
|
omit,
|
|
7
|
-
pick
|
|
8
|
-
|
|
7
|
+
pick,
|
|
8
|
+
rejectObjUndefinedValues
|
|
9
|
+
} from "./chunk-MWND73GM.js";
|
|
9
10
|
export {
|
|
10
11
|
looseGetObjectProperty,
|
|
11
12
|
mapArrayToObject,
|
|
12
13
|
mapObjectToObject,
|
|
13
14
|
objectTypedEntries,
|
|
14
15
|
omit,
|
|
15
|
-
pick
|
|
16
|
+
pick,
|
|
17
|
+
rejectObjUndefinedValues
|
|
16
18
|
};
|
package/lib/testUtils.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
omit,
|
|
3
3
|
pick
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MWND73GM.js";
|
|
5
5
|
import {
|
|
6
6
|
deepEqual
|
|
7
7
|
} from "./chunk-JQFUKJU5.js";
|
|
8
8
|
import {
|
|
9
9
|
arrayWithPrevAndIndex,
|
|
10
10
|
filterAndMap
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-5JQGMNNY.js";
|
|
12
12
|
import {
|
|
13
13
|
clampMin
|
|
14
14
|
} from "./chunk-HTCYUMDR.js";
|