An open API service indexing awesome lists of open source software.

https://github.com/tiaanduplessis/promisify

Convert function to one returning a promise
https://github.com/tiaanduplessis/promisify

function promise

Last synced: 8 months ago
JSON representation

Convert function to one returning a promise

Awesome Lists containing this project

README

          

promisify



Convert function to one returning a promise



npm package version


npm downloads


standard JS linter


prettier code formatting


travis ci build status


project license


make a pull request






Github Watch Badge


Github Star Badge


Tweet





Built with ❤︎ by tiaanduplessis and contributors

Table of Contents

Table of Contents

  • Install

  • Usage

  • Related

  • Contribute

  • License
  • ## Install

    ```sh
    $ npm install @tiaanduplessis/promisify
    # OR
    $ yarn add @tiaanduplessis/promisify
    ```

    ## Usage

    ```js

    const fs = require('fs')
    const promisify = require('@tiaanduplessis/promisify')

    const a = (x) => x;
    const b = (x) => Promise.resolve(x)
    const c = (x) => Promise.reject(x)

    promisify(a)('foo').then(console.log)
    promisify(b)('bar').then(console.log)
    promisify(c)('baz').catch(console.log)
    promisify(fs.readFile)('package.json', 'utf8').then(console.log)

    ```

    # Related

    - [es6-promisify](https://github.com/digitaldesignlabs/es6-promisify)
    - [pify](https://github.com/sindresorhus/pify)

    ## Contributing

    Contributions are welcome!

    1. Fork it.
    2. Create your feature branch: `git checkout -b my-new-feature`
    3. Commit your changes: `git commit -am 'Add some feature'`
    4. Push to the branch: `git push origin my-new-feature`
    5. Submit a pull request :D

    Or open up [a issue](https://github.com/tiaanduplessis/promisify/issues).

    ## License

    Licensed under the MIT License.