@acallaris/promise-js 中文文档教程
@acallaris/promise-js
以前所未有的方式处理 promises
Installation
$ npm install @acallaris/promise-js
Usage
您必须先将其 import
到您的项目中
import { handlePromise, handlePromiseArray } from '@acallaris/promise-js';
// Or
import * as promise from '@acallaris/promise-js';
然后,您可以像这样使用它。
// Handle a single promise
const [data, error] = await handlePromise(yourAsyncFunction());
// Handle an array of promises
const [data, error] = await handlePromiseArray([
yourAsyncFunction(),
anotherAsyncFunction(),
yetAnotherAsyncFunction()
]);
@acallaris/promise-js
Handle promises like never before
Installation
$ npm install @acallaris/promise-js
Usage
You must first import
it to your project
import { handlePromise, handlePromiseArray } from '@acallaris/promise-js';
// Or
import * as promise from '@acallaris/promise-js';
Then, you can use it like this.
// Handle a single promise
const [data, error] = await handlePromise(yourAsyncFunction());
// Handle an array of promises
const [data, error] = await handlePromiseArray([
yourAsyncFunction(),
anotherAsyncFunction(),
yetAnotherAsyncFunction()
]);