maraj 1.0.3 → 1.0.5
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 +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ The **createImmutableUpdate** function has two arguments:
|
|
|
17
17
|
|
|
18
18
|
The **updateObject** has the following syntax:
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
It can accept multiple key-value pairs and the order of execution will be preserved.
|
|
21
21
|
|
|
22
22
|
- **Key:** path name of the fiels, separated by commas (same syntax you use to access object properties)
|
|
23
23
|
(for arrays just use its index value)
|
|
@@ -74,7 +74,7 @@ const person = {
|
|
|
74
74
|
]
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
createImmutableUpdate(person,{
|
|
77
|
+
const newUpdatedObject = createImmutableUpdate(person,{
|
|
78
78
|
'name': Maraj //normal update
|
|
79
79
|
'projects.0.title': 'personal website' //nested update
|
|
80
80
|
'projects.1.available': true //nested update
|
|
@@ -94,7 +94,7 @@ Works with objects(updates its keys) and arrays(adds new values to the array)
|
|
|
94
94
|
```js
|
|
95
95
|
import {spread} from 'maraj'
|
|
96
96
|
|
|
97
|
-
createImmutableUpdate(person,{
|
|
97
|
+
const newUpdatedObject = createImmutableUpdate(person,{
|
|
98
98
|
'additionalInfo.info1': spread({info1: 'new Info'}) //same as (newValue) => (value) => ({...value, ...newValue})
|
|
99
99
|
'projects': spread({title: 'new project'}) //same as (newValueToAdd) => (value) => ([...value, ...newValueToAdd])
|
|
100
100
|
})
|
|
@@ -107,7 +107,7 @@ Removes the key of an object or the index of an array in the key provided in the
|
|
|
107
107
|
```js
|
|
108
108
|
import {remove} from 'maraj'
|
|
109
109
|
|
|
110
|
-
createImmutableUpdate(person,{
|
|
110
|
+
const newUpdatedObject = createImmutableUpdate(person,{
|
|
111
111
|
'additionalInfo': remove('info1') // returns new value (in this case "additionalInfo") without the provided key ("info1")
|
|
112
112
|
'projects': remove(1) // returns new array (in this case "projects") without the provided index (1)
|
|
113
113
|
})
|
|
@@ -122,7 +122,7 @@ import {createSelectorFromStringPath} from 'maraj'
|
|
|
122
122
|
|
|
123
123
|
const stringPath = 'projects.1.data.size'
|
|
124
124
|
|
|
125
|
-
createSelectorFromStringPath(stringPath) // will behave as (store) => store[projects][1][data][size]
|
|
125
|
+
const storeSelector = createSelectorFromStringPath(stringPath) // will behave as (store) => store[projects][1][data][size]
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
### splitPath
|