Skip to content
This repository was archived by the owner on Nov 18, 2021. It is now read-only.

Commit 3de038e

Browse files
committed
改善 readme
1 parent a033527 commit 3de038e

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

README.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
# chrome-call
1+
# chrome-call [![Build Status](https://img.shields.io/travis/Selection-Translator/chrome-call/master.svg?style=flat-square)](https://travis-ci.org/Selection-Translator/chrome-call) [![Coverage Status](https://img.shields.io/coveralls/Selection-Translator/chrome-call/master.svg?style=flat-square)](https://coveralls.io/github/Selection-Translator/chrome-call?branch=master) [![NPM Version](https://img.shields.io/npm/v/chrome-call.svg?style=flat-square)](https://www.npmjs.com/package/chrome-call)
22

3-
[![Build Status](https://img.shields.io/travis/Selection-Translator/chrome-call/master.svg?style=flat-square)](https://travis-ci.org/Selection-Translator/chrome-call)
4-
[![Coverage Status](https://img.shields.io/coveralls/Selection-Translator/chrome-call/master.svg?style=flat-square)](https://coveralls.io/github/Selection-Translator/chrome-call?branch=master)
5-
[![dependencies Status](https://img.shields.io/david/Selection-Translator/chrome-call.svg?style=flat-square)](https://david-dm.org/Selection-Translator/chrome-call)
6-
[![devDependencies Status](https://img.shields.io/david/dev/Selection-Translator/chrome-call.svg?style=flat-square)](https://david-dm.org/Selection-Translator/chrome-call?type=dev)
7-
[![NPM Version](https://img.shields.io/npm/v/chrome-call.svg?style=flat-square)](https://www.npmjs.com/package/chrome-call)
8-
9-
Call the original chrome javascript API and return a Promise.
3+
Call the [Chrome JavasScript APIs](https://developer.chrome.com/extensions/api_index) then return a Promise.
104

115
## Install
126

13-
### Use with Webpack
7+
### Use with webpack
148

159
If you build your project with webpack, then you can install chrome-call from npm:
1610

@@ -47,7 +41,7 @@ When you do:
4741
```js
4842
const promise = new Promise((resolve, reject) => {
4943
chrome.storage.local.get('key', items => {
50-
if(chrome.runtime.lastError){
44+
if (chrome.runtime.lastError) {
5145
reject(chrome.runtime.lastError)
5246
} else {
5347
resolve(items)
@@ -64,7 +58,7 @@ const promise = chromeCall(chrome.storage.local, 'get', 'key')
6458

6559
That's really simple, right?
6660

67-
Some Chrome API methods has more than one arguments, then pass an array of params for the third argument:
61+
Some Chrome JavaScript API methods has more than one arguments, then pass an array of params for the third argument:
6862

6963
```js
7064
chromeCall(chrome.tabs, 'sendMessage', [tabId, message, options])
@@ -74,17 +68,16 @@ chromeCall(chrome.tabs, 'sendMessage', [tabId, message, options])
7468

7569
Most of chrome API only has zero or one argument in callback, but someone not, such as [chrome.hid.receive](https://developer.chrome.com/apps/hid#method-receive).
7670

77-
In this situation, pass `true` as the fourth argument, then the value of promise will be an __real__ Array:
71+
In this situation, pass `true` as the fourth argument, then the value of promise will be an **real** Array:
7872

7973
```js
8074
import chromeCall from 'chrome-call'
8175

82-
chromeCall(chrome.hid, 'receive', connectionId, true)
83-
.then(args => {
84-
Array.isArray(args) // true
85-
const reportId = args[0]
86-
const data = args[1]
87-
})
76+
chromeCall(chrome.hid, 'receive', connectionId, true).then(args => {
77+
Array.isArray(args) // true
78+
const reportId = args[0]
79+
const data = args[1]
80+
})
8881
```
8982

9083
## License

0 commit comments

Comments
 (0)