Skip to content

Commit

Permalink
Tweak readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Bin-Huang committed Nov 23, 2019
1 parent e7a3176 commit 7c54846
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
50 changes: 29 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,33 @@ Prray -- "Promisified" Array, compatible with normal array, but comes with async
```javascript
import { prray } from 'prray'
;(async () => {
// Create a new "prray" from normal array
const prr = prray(['www.google.com', 'npmjs.org'])

// Mapping async function with concurrency limit
const responses = await prr.mapAsync(fetch, { concurrency: 10 })

// Async method chaining 🚀
const htmls = await prr.mapAsync(fetch).mapAsync(r => r.text())

// Method chaining with async and common methods
await prr
.map(commonFunc)
.sortAsync(asyncFunc)
.concat(['github.com', 'wikipedia.org'])
.reverse()
.splice(1, 2)
.reduceAsync(asyncFunc2)
})()
const prr = prray(['www.google.com', 'npmjs.org'])

const responses = await prr.mapAsync(fetch)
```

Async method chaining 🚀

```javascript
const htmls = await prr.mapAsync(fetch).mapAsync(r => r.text())
```

Method chaining with async and common methods

```javascript
await prr
.map(commonFunc)
.sortAsync(asyncFunc)
.concat(['github.com', 'wikipedia.org'])
.reverse()
.splice(1, 2)
.reduceAsync(asyncFunc2)
```

Concurrency limit:

```javascript
const responses = await prr.mapAsync(fetch, { concurrency: 10 })
```

- [Install](#install)
Expand Down Expand Up @@ -68,6 +76,8 @@ yarn add prray

## Compatibility with normal Array

Prray is compatible with normal array. That means you can safely replace normal Array with Prray. And there are [a lots of unit tests](https://github.com/Bin-Huang/prray/tree/master/test) for prray to test compatibility with normal array.

```javascript
import { prray, Prray } from 'prray'

Expand Down Expand Up @@ -104,8 +114,6 @@ function func(arr: number[]) {
func(new Prray(1, 2, 3)) // Type Prray is compatible with type Array in typescript
```

There are [a lots of unit tests](https://github.com/Bin-Huang/prray/tree/master/test) for prray to test compatibility with normal array.

## How it work?

Class Prray inherits the original class Array and adds or overrides methods based on it. It works without any prototype pollution and global pollution.
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prray",
"version": "0.6.2",
"version": "0.6.3",
"description": "'Promisified' Array, comes with async method supports(such as mapAsync). And it is compatible with normal array.",
"main": "./dist/src/index",
"typings": "./dist/src/index.d.ts",
Expand All @@ -20,9 +20,12 @@
"homepage": "https://github.com/Bin-Huang/prray",
"keywords": [
"promise",
"promisified",
"array",
"async",
"p",
"concurrency"
"concurrency",
"bluebird"
],
"author": "Ben Huang",
"license": "MIT",
Expand Down

0 comments on commit 7c54846

Please sign in to comment.