Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gajus/bluefeather
A collection of Promise utilities.
https://github.com/gajus/bluefeather
promise
Last synced: 29 days ago
JSON representation
A collection of Promise utilities.
- Host: GitHub
- URL: https://github.com/gajus/bluefeather
- Owner: gajus
- License: other
- Created: 2016-11-14T09:46:29.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-23T12:45:15.000Z (about 6 years ago)
- Last Synced: 2024-10-05T13:47:54.705Z (about 1 month ago)
- Topics: promise
- Language: JavaScript
- Homepage:
- Size: 27.3 KB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bluefeather
[![Travis build status](http://img.shields.io/travis/gajus/bluefeather/master.svg?style=flat-square)](https://travis-ci.org/gajus/bluefeather)
[![Coveralls](https://img.shields.io/coveralls/gajus/bluefeather.svg?style=flat-square)](https://github.com/gajus/bluefeather)
[![NPM version](http://img.shields.io/npm/v/bluefeather.svg?style=flat-square)](https://www.npmjs.org/package/bluefeather)
[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)A collection of Promise utilities.
* [Utility functions](#utility-functions)
* [`delay`](#delay)
* [`map`](#map)
* [`mapSeries`](#mapseries)
* [`promisify`](#promisify)
* [`suppress`](#suppress)## Utility functions
### `delay`
```js
type DelayType = (ms: number) => Promise;/**
* Creates a promise that is scheduled to resolve after a set delay.
*/
const delay: DelayType;```
### `map`
> For the record, this function is just a thin-wrapper around [`Bluebird#map`](http://bluebirdjs.com/docs/api/promise.map.html).
This method is identical to [`Bluebird#map`](http://bluebirdjs.com/docs/api/promise.map.html) except that the `concurrency` setting can be overridden using `BLUEFEATHER_MAX_CONCURRENCY` environment variable. Controlling max concurrency using environment variables enables debugging of the codebase without refactoring the code.
```js
type MapperType = (currentValue: T, index: number, values: $ReadOnlyArray) => R;type MapConfigurationType = {|
+concurrency: number
|};type MapType = (values: $ReadOnlyArray, mapper: MapperType, configuration?: MapConfigurationType) => Promise<$ReadOnlyArray>;
const map: MapType<*, *>;
```
### `mapSeries`
```js
type CallbackType = (currentValue: T, index: number, values: $ReadOnlyArray) => R;type MapSeriesType = (values: $ReadOnlyArray, mapper: CallbackType) => Promise<$ReadOnlyArray>;
/**
* Creates a promise that is scheduled to resolve after a set delay.
*/
const mapSeries: MapSeriesType<*, *>;```
### `promisify`
```js
/**
* @property multipleArguments Makes the resulting promise fulfill with an array of the callback's success value(s).
*/
type PromisifyOptionsType = {|
multipleArguments?: boolean
|};type PromisifyType = (nodeFunction: Function, options?: PromisifyOptionsType) => Function;
/**
* Creates a function that when executed returns a promise whose fait depends
* on the callback provided as the last parameter to the wrapped function.
*/
const promisify: PromisifyType;```
### `suppress`
```js
type SuppressType = >(
ErrorConstructor: Class | (error: Error) => boolean,
promise: T
) => T | Promise;/**
* Suppresses errors that are instance of ErrorConstructor.
*/
const suppress: SuppressType;```