bluefeather
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -6,4 +6,8 @@ 'use strict'; | ||
}); | ||
exports.promisify = undefined; | ||
exports.promisify = exports.delay = undefined; | ||
var _delay = require('./delay'); | ||
var _delay2 = _interopRequireDefault(_delay); | ||
var _promisify = require('./promisify'); | ||
@@ -15,2 +19,5 @@ | ||
exports.promisify = _promisify2.default; // @flow | ||
// @flow | ||
exports.delay = _delay2.default; | ||
exports.promisify = _promisify2.default; |
@@ -16,5 +16,9 @@ 'use strict'; | ||
|};*/ | ||
/*:: 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. | ||
*/ | ||
/*:: type PromisifyType = (nodeFunction: Function, options?: PromisifyOptionsType) => Function;*/ | ||
const promisify /*: PromisifyType*/ = function promisify(nodeFunction) { | ||
@@ -21,0 +25,0 @@ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
@@ -21,2 +21,3 @@ { | ||
"babel-plugin-transform-flow-comments": "^6.17.0", | ||
"babel-plugin-transform-function-bind": "^6.8.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.16.0", | ||
@@ -70,3 +71,3 @@ "babel-preset-es2015-node4": "^2.1.0", | ||
}, | ||
"version": "1.0.1" | ||
} | ||
"version": "1.1.0" | ||
} |
@@ -8,19 +8,37 @@ # Bluefeather | ||
## API | ||
WIP | ||
### promisify | ||
Bluefeather is a collection of utilities used to abstract common tasks when working with Promises. | ||
Bluefeather does not extend the native Promise prototype. Bluefeather uses the native Promise implentation and leverages the [This-Binding Syntax](https://github.com/tc39/proposal-bind-operator) ECMAScript proposal to implement all of the [Bluebird API](bluebirdjs.com/docs/api-reference.html). | ||
Using Bluefeather requires to transpile code using [`babel-plugin-transform-function-bind`](https://babeljs.io/docs/plugins/transform-function-bind/) Babel plugin. | ||
## Bind operator | ||
Bluefeather leverages the bind-operator proposal | ||
```js | ||
import { | ||
promisify | ||
mapSeries | ||
} from 'bluefeather'; | ||
promisify(nodeFunction, options) | ||
const names = [ | ||
'foo', | ||
'bar', | ||
'baz' | ||
]; | ||
Promise | ||
::mapSeries((value, indexValue) => { | ||
return value + '_'; | ||
}) | ||
.then((values) => { | ||
values; | ||
// [ | ||
// 'foo_', | ||
// 'bar_', | ||
// 'baz_' | ||
// ] | ||
}) | ||
``` | ||
#### Options | ||
|Name|Default|Description| | ||
|---|---|---| | ||
|`context`|`null`|`nodeFunction` is called as a method on the `context`.| | ||
|`multipleArguments`|`false`|Makes the resulting promise fulfill with an array of the callback's success value(s).| |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
44
0
8947
21
104
1