maraj 2.9.0 → 2.10.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/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -35,7 +35,7 @@ type ReturnedValueInPath<TObject, TPath> = TPath extends '' ? TObject : TPath ex
|
|
|
35
35
|
* --------------------------------------------
|
|
36
36
|
*/
|
|
37
37
|
/** Value of a dot-path update object, can be the value or a function. */
|
|
38
|
-
type UpdateValue<TObject, TPath> = ValueInPath<TObject, TPath> extends never ? never : ValueInPath<TObject, TPath> | ((fieldValue: ValueInPath<TObject, TPath>) => ValueInPath<TObject, TPath
|
|
38
|
+
type UpdateValue<TObject, TPath> = ValueInPath<TObject, TPath> extends never ? never : ValueInPath<TObject, TPath> | ((fieldValue: ValueInPath<TObject, TPath>) => Strict<ValueInPath<TObject, TPath>>);
|
|
39
39
|
/** Dot-path update object, used to give updates to the updateImmutably function. */
|
|
40
40
|
type UpdateObject<TObject, TPaths extends DotPaths<TObject> = DotPaths<TObject>> = {
|
|
41
41
|
[Path in TPaths]?: UpdateValue<TObject, Path>;
|
|
@@ -196,14 +196,15 @@ declare const isObjectLiteral: IsObjectLiteral;
|
|
|
196
196
|
|
|
197
197
|
/** Adds strict property to an object literal */
|
|
198
198
|
type StrictFn = <T>(value: T) => Strict<T>;
|
|
199
|
+
declare const strict: StrictFn;
|
|
199
200
|
declare const s: StrictFn;
|
|
200
201
|
/** Checks the strictness of a type passed to a function or callback without 3rd party implementation */
|
|
201
|
-
type
|
|
202
|
-
declare const
|
|
202
|
+
type StrictValueWrapper = <T extends U, U>(v: T extends U ? DotPaths<T> extends DotPaths<U> ? T : Exclude<DotPaths<T>, DotPaths<U>> : never) => U;
|
|
203
|
+
declare const strictValueWrapper: StrictValueWrapper;
|
|
203
204
|
|
|
204
205
|
type ParseStringIndex = (stringKey: string) => number | null;
|
|
205
206
|
declare const parseStringIndex: ParseStringIndex;
|
|
206
207
|
type IsStringIndex = (stringKey: string) => stringKey is `${number}`;
|
|
207
208
|
declare const isStringIndex: IsStringIndex;
|
|
208
209
|
|
|
209
|
-
export { type DotPaths, type ExtendedArrayIndexes, type KeyOf, type LiteralIndex, type ObjectLiteral, type PrimitivesAndNativeObjects, type ReturnedValueInPath, type Strict, type Tuple, type UpdateObject, type UpdateValue, type ValueInPath,
|
|
210
|
+
export { type DotPaths, type ExtendedArrayIndexes, type KeyOf, type LiteralIndex, type ObjectLiteral, type PrimitivesAndNativeObjects, type ReturnedValueInPath, type Strict, type Tuple, type UpdateObject, type UpdateValue, type ValueInPath, experimental_extendableUpdate, forEachEntry, isObjectLiteral, isStringIndex, parseStringIndex, remove, s, select, set, splitPathAtLastKey, strict, strictValueWrapper, update };
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ type ReturnedValueInPath<TObject, TPath> = TPath extends '' ? TObject : TPath ex
|
|
|
35
35
|
* --------------------------------------------
|
|
36
36
|
*/
|
|
37
37
|
/** Value of a dot-path update object, can be the value or a function. */
|
|
38
|
-
type UpdateValue<TObject, TPath> = ValueInPath<TObject, TPath> extends never ? never : ValueInPath<TObject, TPath> | ((fieldValue: ValueInPath<TObject, TPath>) => ValueInPath<TObject, TPath
|
|
38
|
+
type UpdateValue<TObject, TPath> = ValueInPath<TObject, TPath> extends never ? never : ValueInPath<TObject, TPath> | ((fieldValue: ValueInPath<TObject, TPath>) => Strict<ValueInPath<TObject, TPath>>);
|
|
39
39
|
/** Dot-path update object, used to give updates to the updateImmutably function. */
|
|
40
40
|
type UpdateObject<TObject, TPaths extends DotPaths<TObject> = DotPaths<TObject>> = {
|
|
41
41
|
[Path in TPaths]?: UpdateValue<TObject, Path>;
|
|
@@ -196,14 +196,15 @@ declare const isObjectLiteral: IsObjectLiteral;
|
|
|
196
196
|
|
|
197
197
|
/** Adds strict property to an object literal */
|
|
198
198
|
type StrictFn = <T>(value: T) => Strict<T>;
|
|
199
|
+
declare const strict: StrictFn;
|
|
199
200
|
declare const s: StrictFn;
|
|
200
201
|
/** Checks the strictness of a type passed to a function or callback without 3rd party implementation */
|
|
201
|
-
type
|
|
202
|
-
declare const
|
|
202
|
+
type StrictValueWrapper = <T extends U, U>(v: T extends U ? DotPaths<T> extends DotPaths<U> ? T : Exclude<DotPaths<T>, DotPaths<U>> : never) => U;
|
|
203
|
+
declare const strictValueWrapper: StrictValueWrapper;
|
|
203
204
|
|
|
204
205
|
type ParseStringIndex = (stringKey: string) => number | null;
|
|
205
206
|
declare const parseStringIndex: ParseStringIndex;
|
|
206
207
|
type IsStringIndex = (stringKey: string) => stringKey is `${number}`;
|
|
207
208
|
declare const isStringIndex: IsStringIndex;
|
|
208
209
|
|
|
209
|
-
export { type DotPaths, type ExtendedArrayIndexes, type KeyOf, type LiteralIndex, type ObjectLiteral, type PrimitivesAndNativeObjects, type ReturnedValueInPath, type Strict, type Tuple, type UpdateObject, type UpdateValue, type ValueInPath,
|
|
210
|
+
export { type DotPaths, type ExtendedArrayIndexes, type KeyOf, type LiteralIndex, type ObjectLiteral, type PrimitivesAndNativeObjects, type ReturnedValueInPath, type Strict, type Tuple, type UpdateObject, type UpdateValue, type ValueInPath, experimental_extendableUpdate, forEachEntry, isObjectLiteral, isStringIndex, parseStringIndex, remove, s, select, set, splitPathAtLastKey, strict, strictValueWrapper, update };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var N=(e,t)=>{for(var r in t)m(e,r,{get:t[r],enumerable:!0})},F=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of C(t))!W.call(e,s)&&s!==r&&m(e,s,{get:()=>t[s],enumerable:!(n=R(t,s))||n.enumerable});return e};var B=e=>F(m({},"__esModule",{value:!0}),e);var J={};N(J,{experimental_extendableUpdate:()=>A,forEachEntry:()=>v,isObjectLiteral:()=>l,isStringIndex:()=>y,parseStringIndex:()=>E,remove:()=>L,s:()=>V,select:()=>P,set:()=>w,splitPathAtLastKey:()=>g,strict:()=>T,strictValueWrapper:()=>D,update:()=>S});module.exports=B(J);var l=e=>!!e&&Object.getPrototypeOf(e)===Object.prototype,q=Symbol();var H={[q]:[""]};var L=(e,t)=>{if(!Array.isArray(e)&&!l(e))throw'Wrong type provided in "remove" function';let r=Array.isArray(t)?t:[t];if(Array.isArray(e)){let s=Symbol(),o=[...e];return r.forEach(i=>{o[i]=s}),o.filter(i=>i!==s)}let n={...e};return r.forEach(s=>delete n[s]),n};var P=(e,t)=>{if(typeof t!="string")throw new Error("path is not a string");if(!t)return e;let r=t.split("."),n=e;for(;r.length;){let s=r[0],o=r.join(".");if(Object.hasOwn(n,o))return n[o];if(!Object.hasOwn(n,s))return;n=n[s],r.shift()}return n};var g=e=>{if(typeof e!="string")throw new Error(`Wrong dotPath type: ${e}`);let t=e.lastIndexOf(".")+1,r=t?e.slice(0,t-1):"",n=e.slice(t);return[r,n]};var w=e=>()=>e;var E=e=>{let t=parseInt(e);return t.toString()===e?t:null},y=e=>parseInt(e).toString()===e;var K=e=>JSON.stringify(e),f=e=>Array.isArray(e),U=(e,t,r={})=>{if(!l(e)&&!f(e))throw new Error(`"${K(e)}" is not an literalObject/array`);if(!l(t))throw new Error('wrong "updateObject" type provided');let n=Array.isArray(e)?[...e]:{...e},s={};for(let[o,x]of Object.entries(t)){if(o==="")continue;let i=o.split("."),d=s,p=n;for(;i.length>1;){let O=i.join(".");if(Object.hasOwn(p,O)){i=[O];break}let a=i[0],b=p[a],h=l(b),j=f(b);if(!h&&!j&&!(b===void 0)){if(r.onPathsIntersectedByPrimitiveValues==="error")throw new Error(`Property "${a}" in "${o}" is a primitive`);if(r.onPathsIntersectedByPrimitiveValues==="skip")continue}if(!d[a]){if(!h&&!j){let k=f(p)&&y(a),$=y(i[1]),I=k?r.onNewIndexes:r.onNewProps;if(I==="error")throw new Error(`${a} doesn't exist in "${o}"`);if(I==="skip")continue;p[a]=$?[]:{}}else p[a]=j?[...b]:{...b};d[a]={}}p=p[a],d=d[a],i.shift()}let c=i[0],u=p;if(!Object.hasOwn(u,c)){let a=f(u)&&y(c)?r.onNewIndexes:r.onNewProps;if(a==="error")throw new Error(`Property/Index "${c}" doesnt exist in the path "${o}". Its value is: "${K(u)}"`);if(a==="skip")continue}u[c]=typeof x=="function"?x(u[c]):x,delete d[c]}return n},S=(e,t,r)=>U(e,t,r),A=(e,t)=>U(e,t);var v=(e,t)=>Object.keys(e).forEach(r=>t(r,e[r]));var T=e=>e,V=T,D=e=>e;0&&(module.exports={experimental_extendableUpdate,forEachEntry,isObjectLiteral,isStringIndex,parseStringIndex,remove,s,select,set,splitPathAtLastKey,strict,strictValueWrapper,update});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var l=e=>!!e&&Object.getPrototypeOf(e)===Object.prototype,
|
|
1
|
+
var l=e=>!!e&&Object.getPrototypeOf(e)===Object.prototype,w=Symbol();var C={[w]:[""]};var E=(e,t)=>{if(!Array.isArray(e)&&!l(e))throw'Wrong type provided in "remove" function';let r=Array.isArray(t)?t:[t];if(Array.isArray(e)){let i=Symbol(),a=[...e];return r.forEach(o=>{a[o]=i}),a.filter(o=>o!==i)}let n={...e};return r.forEach(i=>delete n[i]),n};var K=(e,t)=>{if(typeof t!="string")throw new Error("path is not a string");if(!t)return e;let r=t.split("."),n=e;for(;r.length;){let i=r[0],a=r.join(".");if(Object.hasOwn(n,a))return n[a];if(!Object.hasOwn(n,i))return;n=n[i],r.shift()}return n};var U=e=>{if(typeof e!="string")throw new Error(`Wrong dotPath type: ${e}`);let t=e.lastIndexOf(".")+1,r=t?e.slice(0,t-1):"",n=e.slice(t);return[r,n]};var S=e=>()=>e;var A=e=>{let t=parseInt(e);return t.toString()===e?t:null},b=e=>parseInt(e).toString()===e;var h=e=>JSON.stringify(e),f=e=>Array.isArray(e),I=(e,t,r={})=>{if(!l(e)&&!f(e))throw new Error(`"${h(e)}" is not an literalObject/array`);if(!l(t))throw new Error('wrong "updateObject" type provided');let n=Array.isArray(e)?[...e]:{...e},i={};for(let[a,x]of Object.entries(t)){if(a==="")continue;let o=a.split("."),y=i,p=n;for(;o.length>1;){let O=o.join(".");if(Object.hasOwn(p,O)){o=[O];break}let s=o[0],u=p[s],m=l(u),j=f(u);if(!m&&!j&&!(u===void 0)){if(r.onPathsIntersectedByPrimitiveValues==="error")throw new Error(`Property "${s}" in "${a}" is a primitive`);if(r.onPathsIntersectedByPrimitiveValues==="skip")continue}if(!y[s]){if(!m&&!j){let P=f(p)&&b(s),g=b(o[1]),T=P?r.onNewIndexes:r.onNewProps;if(T==="error")throw new Error(`${s} doesn't exist in "${a}"`);if(T==="skip")continue;p[s]=g?[]:{}}else p[s]=j?[...u]:{...u};y[s]={}}p=p[s],y=y[s],o.shift()}let c=o[0],d=p;if(!Object.hasOwn(d,c)){let s=f(d)&&b(c)?r.onNewIndexes:r.onNewProps;if(s==="error")throw new Error(`Property/Index "${c}" doesnt exist in the path "${a}". Its value is: "${h(d)}"`);if(s==="skip")continue}d[c]=typeof x=="function"?x(d[c]):x,delete y[c]}return n},v=(e,t,r)=>I(e,t,r),V=(e,t)=>I(e,t);var D=(e,t)=>Object.keys(e).forEach(r=>t(r,e[r]));var L=e=>e,k=L,$=e=>e;export{V as experimental_extendableUpdate,D as forEachEntry,l as isObjectLiteral,b as isStringIndex,A as parseStringIndex,E as remove,k as s,K as select,S as set,U as splitPathAtLastKey,L as strict,$ as strictValueWrapper,v as update};
|