Skip to content

Commit 94c85ee

Browse files
committed
docs: update README
1 parent 99d2597 commit 94c85ee

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

readme.md

+33-10
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
To setup MiniJS in your local machine, you can do the following:
66

7-
1. Clone [repository](https://github.com/Group-One-Technology/minijs).
7+
1. Clone the [repository](https://github.com/Group-One-Technology/minijs).
88
2. Run `npm install` to install dependencies.
9-
3. Run `npm run build` to create a `dist` -> output for MiniJS.
10-
4. Run `npm run dev` to run demo page locally.
11-
5. Run `npm run build-watch` to run build when code changes.
9+
3. Run `npm run build` to create the `dist` folder -> output for MiniJS.
10+
4. Run `npm run dev` to run the demo page locally.
11+
5. Run `npm run build-watch` on another terminal to build the code whenever the Mini.js code changes.
1212

1313
## The Idea
1414

@@ -201,49 +201,72 @@ Here are the custom array methods which are available for you to use:
201201

202202
- `first` - returns the first item in the array.
203203
Usage: `array.first`
204+
204205
```js
205206
array = ['Cherries', 'Chocolate', 'Blueberry', 'Vanilla']
206-
array.last // returns 'Vanilla'
207+
array.first // returns 'Cherries'
207208
```
209+
208210
- `last` - returns the last item in the array.
209211
Usage: `array.last`
212+
210213
```js
211214
array = ['Cherries', 'Chocolate', 'Blueberry', 'Vanilla']
212-
array.first // returns 'Cherries'
215+
array.last // returns 'Vanilla'
213216
```
217+
214218
- `search` - returns an array of items that match the query.
215219
Usage: `array.search('query')`
220+
216221
```js
217222
array = ['Cherries', 'Chocolate', 'Blueberry', 'Vanilla']
218223
array.search('c') // returns ['Cherries', 'Chocolate']
219224
```
220-
- `toggle`
221-
Usage: `array.toggle('item')`
225+
222226
- `add` - adds an item to the array if it doesn't exist.
223227
Usage: `array.add('item')`
228+
224229
```js
225230
array = ['Tag 1', 'Tag 2', 'Tag 3', 'Tag 4']
226231
array.add('Tag 5') // returns ['Tag 1', 'Tag 2', 'Tag 3', 'Tag 4', 'Tag 5']
227232
```
233+
228234
- `remove` - removes an item from the array if it exists.
229235
Usage: `array.remove('item')`
236+
230237
```js
231238
array = ['Tag 1', 'Tag 2', 'Tag 3', 'Tag 4']
232239
array.remove('Tag 2') // returns ['Tag 1', 'Tag 3', 'Tag 4']
233240
```
234-
- `nextItem` - gets the next item in the array.
241+
242+
- `toggle` - removes / adds the item in the array
243+
Usage: `array.toggle('item')`
244+
245+
```js
246+
array = ['Cherries', 'Chocolate', 'Blueberry', 'Vanilla']
247+
array.toggle('Cherries') // removes 'Cherries'
248+
// returns ['Chocolate', 'Blueberry', 'Vanilla']
249+
250+
array.toggle('Cherries') // re-adds 'Cherries'
251+
// returns ['Cherries', 'Chocolate', 'Blueberry', 'Vanilla']
252+
```
253+
254+
- `nextItem` - gets the next item based on the given item in the array.
235255
Usage: `array.nextItem('item')`
236256
```js
237257
array = ['Tag 1', 'Tag 2', 'Tag 3', 'Tag 4']
238258
array.nextItem('Tag 2') // returns 'Tag 3'
239259
```
240-
- `previousItem` - gets the next item in the array.
260+
- `previousItem` - gets the next item based on the given item in the array.
241261
Usage: `array.previousOf('item')`
262+
242263
```js
243264
array = ['Tag 1', 'Tag 2', 'Tag 3', 'Tag 4']
244265
array.previousItem('Tag 2') // returns 'Tag 1'
245266
```
246267

268+
#### Triggering Array Updates
269+
247270
To trigger a re-render you need to update the variable:
248271

249272
```js

0 commit comments

Comments
 (0)