@homedev/object-utils 1.0.2 → 1.0.4
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/dist/index.d.ts +29 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
*/
|
|
4
|
+
export declare const asyncMap: <T, U>(arr: T[], fn: (item: T, index: number, array: T[]) => Promise<U>) => Promise<U[]>;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare const defined: <T>(value: T | undefined, msg?: string) => T;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare const nonNullMap: <T, U>(arr: T[] | undefined, fn: (item: T, index: number, array: T[]) => U) => U[];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare const sortBy: <T, U>(arr: T[], selector: (item: T) => U, compare?: (a: U, b: U) => number) => T[];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
1
24
|
export declare const toList: <T>(from: any, key?: string) => T[];
|
|
2
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
3
29
|
export declare const toObject: <T>(from: any[], key?: string) => T;
|
|
4
30
|
|
|
31
|
+
/**
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
5
34
|
export declare const toObjectWithKey: <T>(from: any[], key?: string) => T;
|
|
6
35
|
|
|
7
36
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var o=(e,n="name")=>Object.entries(e).map(([t,r])=>({[n]:t,...r})),s=(e,n="name")=>Object.fromEntries(e.map((t)=>[t[n],t])),T=(e,n="name")=>Object.fromEntries(e.map((t)=>{let{[n]:r,...a}=t;return[r,a]})),i=(e,n)=>e?.filter((t)=>t!==null&&t!==void 0).map(n)??[],m=(e,n="Value is undefined")=>{if(e===void 0)throw Error(n);return e},c=(e,n,t=(r,a)=>r-a)=>e.slice().sort((r,a)=>t(n(r),n(a))),p=async(e,n)=>Promise.all(e.map(n));export{s as toObjectWithKey,T as toObject,o as toList,c as sortBy,i as nonNullMap,m as defined,p as asyncMap};
|