@homedev/object-utils 1.0.3 → 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 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{defineProperty:o,getOwnPropertyNames:c,getOwnPropertyDescriptor:T}=Object,m=Object.prototype.hasOwnProperty;var s=new WeakMap,b=(e)=>{var t=s.get(e),n;if(t)return t;if(t=o({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")c(e).map((a)=>!m.call(t,a)&&o(t,a,{get:()=>e[a],enumerable:!(n=T(e,a))||n.enumerable}));return s.set(e,t),t};var j=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0,configurable:!0,set:(a)=>t[n]=()=>a})};var i={};j(i,{toObjectWithKey:()=>y,toObject:()=>O,toList:()=>p});module.exports=b(i);var p=(e,t="name")=>Object.entries(e).map(([n,a])=>({[t]:n,...a})),y=(e,t="name")=>Object.fromEntries(e.map((n)=>[n[t],n])),O=(e,t="name")=>Object.fromEntries(e.map((n)=>{let{[t]:a,...r}=n;return[a,r]}));
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homedev/object-utils",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "object utilities",
5
5
  "author": "julzor",
6
6
  "license": "ISC",