maraj 1.0.2 → 1.0.4
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 +9 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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
|
|
@@ -88,13 +88,13 @@ createImmutableUpdate(person,{
|
|
|
88
88
|
|
|
89
89
|
### spread
|
|
90
90
|
|
|
91
|
-
Spreads its argument into the key provided in the createImmutableUpdate
|
|
91
|
+
Spreads its argument into the key provided in the **createImmutableUpdate.**
|
|
92
92
|
Works with objects(updates its keys) and arrays(adds new values to the array)
|
|
93
93
|
|
|
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
|
})
|
|
@@ -102,12 +102,12 @@ createImmutableUpdate(person,{
|
|
|
102
102
|
|
|
103
103
|
### remove
|
|
104
104
|
|
|
105
|
-
Removes the key of an object or the index of an array in the key provided in the createImmutableUpdate
|
|
105
|
+
Removes the key of an object or the index of an array in the key provided in the **createImmutableUpdate.**
|
|
106
106
|
|
|
107
107
|
```js
|
|
108
|
-
import {
|
|
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
|
})
|
|
@@ -118,9 +118,11 @@ createImmutableUpdate(person,{
|
|
|
118
118
|
Creates a store selector from provided string path. Usefull in cases like getting data from Redux, Zustand, and so on. stores.
|
|
119
119
|
|
|
120
120
|
```js
|
|
121
|
+
import {createSelectorFromStringPath} from 'maraj'
|
|
122
|
+
|
|
121
123
|
const stringPath = 'projects.1.data.size'
|
|
122
124
|
|
|
123
|
-
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]
|
|
124
126
|
```
|
|
125
127
|
|
|
126
128
|
### splitPath
|