@homedev/object-utils 1.0.5 → 1.0.6

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
@@ -25,12 +25,12 @@ export declare const deepClone: <T>(model: T) => T;
25
25
  * Asserts that a value is defined, throwing an error if undefined
26
26
  * @typeParam T - Type of the value
27
27
  * @param value - Value to check
28
- * @param msg - Error message to throw if value is undefined
28
+ * @param msg - Error message to throw if value is undefined or null
29
29
  * @returns The value if defined
30
30
  * @throws Error if value is undefined
31
31
  * @public
32
32
  */
33
- export declare const defined: <T>(value: T | undefined, msg?: string) => T;
33
+ export declare const defined: <T>(value: T | undefined | null, msg?: string) => T;
34
34
 
35
35
  /**
36
36
  * Maps an array while filtering out null/undefined values (performance optimized)
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var A=(h,j="name")=>Object.entries(h).map(([q,w])=>({[j]:q,...w})),B=(h,j="name")=>Object.fromEntries(h.map((q)=>[q[j],q])),D=(h,j="name")=>Object.fromEntries(h.map((q)=>{let{[j]:w,...z}=q;return[w,z]})),E=(h,j)=>{if(!h)return[];let q=[],w=0;for(let z of h)if(z!==null&&z!==void 0)q.push(j(z,w,h)),w++;return q},F=(h,j="Value is undefined")=>{if(h===void 0)throw Error(j);return h},G=(h,j,q=(w,z)=>w-z)=>h.slice().sort((w,z)=>q(j(w),j(z))),H=async(h,j)=>Promise.all(h.map(j)),I=(h)=>{if(typeof structuredClone<"u")try{return structuredClone(h)}catch{}return JSON.parse(JSON.stringify(h))};export{B as toObjectWithKey,D as toObject,A as toList,G as sortBy,E as nonNullMap,F as defined,I as deepClone,H as asyncMap};
1
+ var A=(h,j="name")=>Object.entries(h).map(([q,w])=>({[j]:q,...w})),B=(h,j="name")=>Object.fromEntries(h.map((q)=>[q[j],q])),D=(h,j="name")=>Object.fromEntries(h.map((q)=>{let{[j]:w,...z}=q;return[w,z]})),E=(h,j)=>{if(!h)return[];let q=[],w=0;for(let z of h)if(z!==null&&z!==void 0)q.push(j(z,w,h)),w++;return q},F=(h,j="Value is undefined")=>{if(h===void 0||h===null)throw Error(j);return h},G=(h,j,q=(w,z)=>w-z)=>h.slice().sort((w,z)=>q(j(w),j(z))),H=async(h,j)=>Promise.all(h.map(j)),I=(h)=>{if(typeof structuredClone<"u")try{return structuredClone(h)}catch{}return JSON.parse(JSON.stringify(h))};export{B as toObjectWithKey,D as toObject,A as toList,G as sortBy,E as nonNullMap,F as defined,I as deepClone,H as asyncMap};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homedev/object-utils",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "object utilities",
5
5
  "author": "julzor",
6
6
  "license": "ISC",