Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Bin-Huang committed Dec 4, 2019
1 parent 6b368f0 commit 94ee199
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,37 +133,21 @@ arr instanceof Prray // false

## Methods

### Package methods

- [Prray.from(array)](#prrayarray)
- [new Prray()](#new-prray)

#### Prray.from(array)

The Prray.from() method creates and returns a new Prray instance with every element in the array.

```javascript
import Prray from 'prray'

const prr = Prray.from([1, 2, 3])
console.log(prr[0]) // 1
```

#### new Prray()
### Class Prray

The class `Prray`. You can think of it as class `Array`.

```javascript
import Prray from 'prray'

const p1 = new Prray()
const p2 = new Prray(1)
const p3 = new Prray('a', 'b')
const p2 = new Prray('a', 'b')
const p3 = Prray.from([1, 2, 3, 4])

console.log(p3[0]) // 'a'
console.log(p2[0]) // 'a'
```

> **Instead `new Prray()`, use methods `prray`, `Prray.from` or `Prray.of` if you want to create a new prray instance**. Because the class Prray is so compatible with class Array, some "weird" behaviors that exists in `new Array()` can also occurs: when you calling `new Array(1)`, you get `[ <1 empty item> ]` instead of expected `[ 1 ]`.
**Instead `new Prray()`, use `Prray.from` or `Prray.of` if you want to create a new prray instance**. Because the class Prray is so compatible with class Array, some "weird" behaviors that exists in `new Array()` can also occurs: when you calling `new Array(1)`, you get `[ <1 empty item> ]` instead of expected `[ 1 ]`.

### Static methods of Class Prray

Expand Down

0 comments on commit 94ee199

Please sign in to comment.