maraj 2.7.0 → 2.7.1

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/README.md CHANGED
@@ -12,7 +12,7 @@ A fast lightweight utility for creating **immutable updates**. Fully typed. Only
12
12
  - Multiple and concurrent updates.
13
13
  - Nested functional updates.
14
14
 
15
- <u>**For Typescript:**</u> in tsconfig.json set **"strictNullChecks"** and **"noUncheckedIndexedAccess"** to **true** to be able to infer correctly the type of optional properties and properties with posible undefined value. ({key?: ''} !== {key: '' | undefined})
15
+ <u>**For Typescript:**</u> in tsconfig.json set **"strictNullChecks"** and **"noUncheckedIndexedAccess"** to **true** to be able to infer correctly the type of *optional properties* and *properties with posible undefined value*. ( { key?: ... } is not equal to { key: ... | undefined } )
16
16
 
17
17
  ```ts
18
18
  const originalValue = { name: 'one', lastname: 'two' modified: false, files: [{ filename: 'one' }] }
package/dist/index.d.mts CHANGED
@@ -74,7 +74,7 @@ type DotPaths<T, TAllowedTypes = any> = T extends ReadonlyArray<infer U> ? IsTup
74
74
  * --------------------------------------------
75
75
  */
76
76
  /** Nested type implementation. */
77
- type ValueInPath<TObject, TPath> = TPath extends '' ? TObject : TPath extends keyof TObject ? TObject[TPath] : TPath extends LiteralIndex ? never : TPath extends `${number}` ? TObject extends ReadonlyArray<infer U> ? U : never : TPath extends `${infer K}.${infer R}` ? K extends keyof TObject ? ValueInPath<TObject[K], R> : K extends LiteralIndex ? never : K extends `${number}` ? TObject extends ReadonlyArray<infer U> ? ValueInPath<U, R> : never : never : never;
77
+ type ValueInPath<TObject, TPath> = TPath extends keyof TObject ? TObject[TPath] : TPath extends '' ? TObject : TPath extends LiteralIndex ? never : TPath extends `${number}` ? TObject extends ReadonlyArray<infer U> ? U : never : TPath extends `${infer K}.${infer R}` ? K extends keyof TObject ? ValueInPath<TObject[K], R> : K extends LiteralIndex ? never : K extends `${number}` ? TObject extends ReadonlyArray<infer U> ? ValueInPath<U, R> : never : never : never;
78
78
  /**
79
79
  * --------------------------------------------
80
80
  * RETURNED VALUE OF A NESTED PROPERTY PROVIDING A DOT PATH
@@ -90,8 +90,8 @@ type ReturnedValueInPath<TObject, TPath> = TPath extends '' ? TObject : TPath ex
90
90
  /** Value of a dot-path update object, can be the value or a function. */
91
91
  type UpdateValue<TObject, TPath> = ValueInPath<TObject, TPath> | ((fieldValue: ValueInPath<TObject, TPath>) => ValueInPath<TObject, TPath>);
92
92
  /** Dot-path update object, used to give updates to the updateImmutably function. */
93
- type UpdateObject<TObject> = {
94
- [TPath in DotPaths<TObject>]?: ValueInPath<TObject, TPath> | ((fieldValue: ValueInPath<TObject, TPath>) => ValueInPath<TObject, TPath>);
93
+ type UpdateObject<TObject, TPaths extends PropertyKey = DotPaths<TObject>> = {
94
+ [TPath in TPaths]?: ValueInPath<TObject, TPath> | ((fieldValue: ValueInPath<TObject, TPath>) => ValueInPath<TObject, TPath>);
95
95
  };
96
96
  /**
97
97
  * --------------------------------------------
package/dist/index.d.ts CHANGED
@@ -74,7 +74,7 @@ type DotPaths<T, TAllowedTypes = any> = T extends ReadonlyArray<infer U> ? IsTup
74
74
  * --------------------------------------------
75
75
  */
76
76
  /** Nested type implementation. */
77
- type ValueInPath<TObject, TPath> = TPath extends '' ? TObject : TPath extends keyof TObject ? TObject[TPath] : TPath extends LiteralIndex ? never : TPath extends `${number}` ? TObject extends ReadonlyArray<infer U> ? U : never : TPath extends `${infer K}.${infer R}` ? K extends keyof TObject ? ValueInPath<TObject[K], R> : K extends LiteralIndex ? never : K extends `${number}` ? TObject extends ReadonlyArray<infer U> ? ValueInPath<U, R> : never : never : never;
77
+ type ValueInPath<TObject, TPath> = TPath extends keyof TObject ? TObject[TPath] : TPath extends '' ? TObject : TPath extends LiteralIndex ? never : TPath extends `${number}` ? TObject extends ReadonlyArray<infer U> ? U : never : TPath extends `${infer K}.${infer R}` ? K extends keyof TObject ? ValueInPath<TObject[K], R> : K extends LiteralIndex ? never : K extends `${number}` ? TObject extends ReadonlyArray<infer U> ? ValueInPath<U, R> : never : never : never;
78
78
  /**
79
79
  * --------------------------------------------
80
80
  * RETURNED VALUE OF A NESTED PROPERTY PROVIDING A DOT PATH
@@ -90,8 +90,8 @@ type ReturnedValueInPath<TObject, TPath> = TPath extends '' ? TObject : TPath ex
90
90
  /** Value of a dot-path update object, can be the value or a function. */
91
91
  type UpdateValue<TObject, TPath> = ValueInPath<TObject, TPath> | ((fieldValue: ValueInPath<TObject, TPath>) => ValueInPath<TObject, TPath>);
92
92
  /** Dot-path update object, used to give updates to the updateImmutably function. */
93
- type UpdateObject<TObject> = {
94
- [TPath in DotPaths<TObject>]?: ValueInPath<TObject, TPath> | ((fieldValue: ValueInPath<TObject, TPath>) => ValueInPath<TObject, TPath>);
93
+ type UpdateObject<TObject, TPaths extends PropertyKey = DotPaths<TObject>> = {
94
+ [TPath in TPaths]?: ValueInPath<TObject, TPath> | ((fieldValue: ValueInPath<TObject, TPath>) => ValueInPath<TObject, TPath>);
95
95
  };
96
96
  /**
97
97
  * --------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maraj",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "description": "A lightweight 600 bytes gzipped alternative for immutable updates while dealing with objects and arrays",
5
5
  "keywords": [
6
6
  "shallow",