Skip to content

Commit 73a32d8

Browse files
committed
docs: cleanup
1 parent c0730f4 commit 73a32d8

File tree

1 file changed

+3
-28
lines changed

1 file changed

+3
-28
lines changed

README.md

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ console.log(data); // output: { list: [ { value: 42 } ] }
119119

120120
#### behaviour using `set`
121121

122-
`set` will create arrays when encountering a number
122+
`set` will **create arrays** when encountering a number
123123

124124
```js
125125
pointer.set({}, ['list', '1', 'value'], 42);
@@ -133,14 +133,14 @@ pointer.set({}, ['list', '[1]', 'value'], 42);
133133
// { list: [undefined, { value: 42 }] }
134134
```
135135

136-
append items using empty array syntax `[]`
136+
**append items** using empty array syntax `[]`
137137

138138
```js
139139
pointer.set({ list: [1, 2] }, ['list', '[]', 'value'], 42);
140140
// { list: [1, 2, { value: 42 }] }
141141
```
142142

143-
create object using object syntax `{index}`
143+
**create object** using object syntax `{index}`
144144

145145
```js
146146
pointer.set({}, ['list', '{1}', 'value'], 42);
@@ -155,31 +155,6 @@ pointer.set({}, ['list', '{1}', 'value'], 42);
155155
> ```
156156
157157
158-
159-
#### array
160-
161-
Per default `set` creates objects for each each missing data. Thus, a pointer to `/list/1` will create an object with `{ list: { 1: {} } }`. If you want to specify array-data you will need to wrap the array-index in array-brackets:
162-
163-
```ts
164-
pointer.set({}, '/list/[1]', 42);
165-
// { list: [, 42] }
166-
```
167-
168-
Omitting the index from the array-brackets will **append** the item:
169-
170-
```ts
171-
pointer.set({}, '/list/[]', 42);
172-
// { list: [42] }
173-
```
174-
175-
which also works for existing lists:
176-
177-
```ts
178-
pointer.set({ list: ["first"] }, '/list/[]', 42);
179-
// { list: ["first", 42] }
180-
```
181-
182-
183158
### remove
184159
185160
> remove(data:object|array, pointer:string|array) -> data:object|array

0 commit comments

Comments
 (0)