relike-all

Promisify all function in an object, using relike.
Install
npm i relike-all --save
Usage
For more use-cases see the tests
const relikeAll =
relikeAll
Promisify functions in an object. You can pass
pattern
to filter what should be promisified and what not. Using is-match, which is thin wrapper around micromatch. You should install is-match, if you want to use filtering.
Params
<source>
{Object|Function}: The source object to promisify.[pattern]
{String|Array|RegExp|Function}: A glob pattern to filter, using micromatch.[options]
{Object}: Options passed to micromatch.returns
{Object|Function}: Same as incomingsource
.
Example
const relikeAll = const fs = fs
.promisify
Returns a function that will wrap the given
fn
. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the givenfn
node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument. – Bluebird Docs on.promisify
Params
fn
{Function}: Some sync or async function to promisify.[Promize]
{Function}: Promise constructor to be used on enviroment where no support for native.returns
{Function}: Promisified function, which always return a Promise.
Example
const fs = const relikeAll = const readFile = relikeAll
.Promise
Customizing what Promise constructor to be used in old environments where there's no support for native Promise.
See more in relike's.Promise
section for more info.
Example
const fs = const relikeAll = // using `when` promise on node <= 0.11.12relikeAllpromisifyPromise = const readFile = relikeAllconst promise = console // => The `when` promise constructor, on old enviromentsconsole // => `true` on old environments
Related
- hybridify: Hybridify. Hybrids. Create sync, async or generator function to support both promise… more | homepage
- letta-value: Extends
letta
to accept and handles more than functions only. Handles all… more | homepage - letta: Promisify sync, async or generator function, using relike. Kind of promisify, but… more | homepage
- relike-value: Create promise from sync, async, string, number, array and so on. Handle… more | homepage
- relike: Simple promisify async or sync function with sane defaults. Lower level than… more | homepage
- value2stream: Transform any value to stream. Create a stream from any value -… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.