![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
immutable-path
Advanced tools
Immutable `get`, `set`, `has`, `unset` deep path operations libraray for object, array and `Map`.
Immutable get
, set
, has
, unset
deep path operations libraray for object, array and Map
.
const object = { a: "a", b: [0, 1], c: new Map([["x", "x"]]) };
set(object, "a", "new"); // { a: "new", b: [0, 1], c: new Map([["x", "x"]]) };
set(object, "a.c.x", "new"); // { a: "new", b: [0, 1], c: new Map([["x", "new"]]) };
set(object, "a.c.x", "new"); // { a: "new", b: [0, 1], c: new Map([["x", "new"]]) };
unset(object, "a.c.x"); // { a: "new", b: [0, 1], c: new Map() };
unset(object, "a.c.x", { unsetEmpty: true }); // { a: "new", b: [0, 1] };
const otherObject = { a: "a", b: new CustomClass() };
set(otherObject, "b.x", "new", { atomicClasses: CustomClass }); // { a: "a", b: "x" }
Update, get, delete or check existence of keys of deeply nested objects, keys and Map
s.
Ƭ Class: object
Defined in util/types.ts:1
Ƭ Key: keyof S | KeyOfMap‹S›
Defined in util/types.ts:13
Object key or arrau index.
Ƭ KeyOfMap: M extends Map<infer K, unknown> ? K : never
Defined in util/types.ts:7
Ƭ Path: string | number | Array‹string | number›
Defined in util/types.ts:5
Ƭ SetFunction: function
Defined in util/types.ts:42
Returned value from this function is used as new value to be set.
▸ (value
: S[K], key
: K, source
: S, root
: any): S[K]
qefjewoıh
Parameters:
Name | Type | Description |
---|---|---|
value | S[K] | is the current value of given key/index. |
key | K | is the current key/index of value to be replaced. |
source | S | is the object/array/Map which has the key/index. |
root | any | is the root object/array/Map. |
Ƭ Source: Array‹any› | Map‹any, any› | Record‹any, any›
Defined in util/types.ts:3
Const
defaultAtomicClasses• defaultAtomicClasses: Class[] = [Date, RegExp]
Defined in util/helper.ts:7
List of default atomic classes.
▸ get<S>(source
: S, path
: Path, defaultValue?
: any): any
Defined in immutable-object-path.ts:89
Gets the property value at path of object/array/Map. If the resolved value is undefined the defaultValue is used in its place.
Type parameters:
▪ S: Source
Parameters:
Name | Type | Description |
---|---|---|
source | S | is the object/array/map to query. |
path | Path | is the path of the property to get. |
defaultValue? | any | is the value returned if the resolved value is undefined . |
Returns: any
the resolved value.
▸ has<S>(source
: S, path
: Path): any
Defined in immutable-object-path.ts:106
Checks if path is a direct property of object/array/Map.
Type parameters:
▪ S: Source
Parameters:
Name | Type | Description |
---|---|---|
source | S | is the object/array/Map to query. |
path | Path | is the path to check. |
Returns: any
whether path is a direct property of object/array/Map.
▸ set<S>(source
: S, path
: Path, value
: any, __namedParameters
: object, root
: any): any
Defined in immutable-object-path.ts:25
Sets the property value of path on object/array/Map immutably without changing input. If a portion of path does not exist it's created.
Provided atomicClasses
is used to determine which type of objects are treated as atomic. Atomic classes are
treated like primitives pretending they don't have attributes. See example below. If preferMap
is true,
when new objects are needed, they are created as Map
instead of object.
const a = set({ x: new Date() }, "x.y", 3); // 3 is not assigned to atomic class Date. Insted it is replaced: { x: { y: 3 } }
const b = set({ x: { z: 1 } }, "x.y", 3); // 3 is not assigned to `x.y`: { x: { y: 3, z: 1 } }
const c = set({ }, "x.y", 3); // 3 is not assigned to `x.y`: { x: { y: 3 } }
const c = set({ }, "x.y", 3, { preferMap: true }); // Map([[x, new Map([[y, 3]])]]);
Type parameters:
▪ S: Source
Parameters:
▪ source: S
is the object/array/map to set.
▪ path: Path
is the path of the property to set.
▪ value: any
is the value to set.
▪Default value
__namedParameters: object= {}
are options.
Name | Type | Default | Description |
---|---|---|---|
atomicClasses | object[] | defaultAtomicClasses | Atomic classes are treated like a scalar, because MOST PROBABLY user did not intend to update a property of it. Instead they want to replace it. |
preferMap | boolean | false | If an attribute for a non-existing object should be created, whether to create a Map instead of object . |
▪Default value
root: any= source
Returns: any
new object/array/Map.
▸ unset<S>(source
: S, path
: Path, __namedParameters
: object): any
Defined in immutable-object-path.ts:52
Removes the property at path of object and returns it. Does not change input value.
Type parameters:
▪ S: Source
Parameters:
▪ source: S
is the object/array/map to unset a value.
▪ path: Path
is the path of the property to unset.
▪Default value
__namedParameters: object= {}
are options.
Name | Type | Default | Description |
---|---|---|---|
atomicClasses | object[] | defaultAtomicClasses | Atomic classes are treated like a scalar, because MOST PROBABLY user did not intend to update a property of it. Instead they want to replace it. |
preferMap | boolean | false | If an attribute for a non-existing object should be created, whether to create a Map instead of object . |
unsetEmpty | boolean | true | After unsetting a key/index if object/array/Map becomes empty, it is also unset in parent. |
Returns: any
new object/array/Map.
Options
Options
Optional
atomicClasses• atomicClasses? : Class[]
Defined in util/types.ts:30
Atomic classes are treated like a scalar, because MOST PROBABLY user did not intend to update a property of it. Instead they want to replace it.
set([new Date()], "0.a", "x"); // => [{ a: "x" }] NOT [a Date with an attribute "x"]
Optional
preferMap• preferMap? : undefined | false | true
Defined in util/types.ts:23
If an attribute for a non-existing object should be created, whether to create a Map
instead of object
.
Unset options.
↳ UnsetOptions
Optional
atomicClasses• atomicClasses? : Class[]
Inherited from Options.atomicClasses
Defined in util/types.ts:30
Atomic classes are treated like a scalar, because MOST PROBABLY user did not intend to update a property of it. Instead they want to replace it.
set([new Date()], "0.a", "x"); // => [{ a: "x" }] NOT [a Date with an attribute "x"]
Optional
preferMap• preferMap? : undefined | false | true
Inherited from Options.preferMap
Defined in util/types.ts:23
If an attribute for a non-existing object should be created, whether to create a Map
instead of object
.
Optional
unsetEmpty• unsetEmpty? : undefined | false | true
Defined in util/types.ts:36
After unsetting a key/index if object/array/Map becomes empty, it is also unset in parent.
FAQs
Immutable `get`, `set`, `has`, `unset` deep path operations libraray for object, array and `Map`.
The npm package immutable-path receives a total of 140 weekly downloads. As such, immutable-path popularity was classified as not popular.
We found that immutable-path demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.