maraj 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/README.md +17 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -93,20 +93,21 @@ const newUpdatedObject = createImmutableUpdate(person,{
93
93
 
94
94
  Spreads its argument into the key provided in the **createImmutableUpdate.**
95
95
 
96
- Works with objects(updates its keys) and arrays(adds new values to the array)
96
+ Works with **objects (updates its keys)**, **arrays (adds new values to the array)** and **any other value (sets the new value)**
97
97
 
98
98
  ```js
99
99
  import {spread} from 'maraj'
100
100
 
101
101
  const newUpdatedObject = createImmutableUpdate(person,{
102
- 'additionalInfo.info1': spread({info1: 'new Info'}), //same as (newValue) => (value) => ({...value, ...newValue})
102
+ 'additionalInfo': spread({info1: 'new Info'}), //same as (newValue) => (value) => ({...value, ...newValue})
103
103
  'projects': spread({title: 'new project'}) //same as (newValueToAdd) => (value) => ([...value, ...newValueToAdd])
104
+ 'additionalInfo.info1': spread('new project') //same as (newValue) => (value) => (newValue)
104
105
  })
105
106
  ```
106
107
 
107
108
  ### remove
108
109
 
109
- Removes the key of an object or the index of an array in the key provided in the **createImmutableUpdate.**
110
+ Removes the **key of an object** or the **index of an array** in the key provided in the **createImmutableUpdate.**
110
111
 
111
112
  ```js
112
113
  import {remove} from 'maraj'
@@ -119,7 +120,7 @@ const newUpdatedObject = createImmutableUpdate(person,{
119
120
 
120
121
  ### createSelectorFromStringPath
121
122
 
122
- Creates a store selector from provided string path.
123
+ **Creates a store selector** from provided string path.
123
124
 
124
125
  Usefull in cases like getting data from Redux, Zustand, and so on. stores.
125
126
 
@@ -137,4 +138,15 @@ Usefull when you want to spread multiple values into objects dynamically
137
138
 
138
139
  Splits string path (example:'projects.1.data.size' ) into two:
139
140
  - id: the last key in the path (in this case 'size')
140
- - remainingPath: the remaining path (in this case 'projects.1.data')
141
+ - remainingPath: the remaining path (in this case 'projects.1.data')
142
+
143
+
144
+ ```js
145
+ import {splitPath} from 'maraj'
146
+
147
+ const stringPath = 'projects.1.data.size'
148
+
149
+ const { id, remainingPath } = splitPath(stringPath)
150
+ // id = 'size'
151
+ // remainingPath = 'projects.1.data'
152
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maraj",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "A lightweight 600 bytes gzipped alternative for immutable updates while dealing with objects and arrays",
5
5
  "main": "index.js",
6
6
  "scripts": {