deepsweet / makethen

:sparkles: Promisify Node.js-style callbacks with native Promise

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

makethen

⚠️ Project has been transferred to NexTools metarepo

npm tests coverage

Strongly typed (up to 3 arguments and 3 result params) promisify for Node.js-style callbacks.

Requirements

  • Node.js >= 8.6.0

Install

$ yarn add makethen

Usage

import { readFile } from 'fs'
import makethen from 'makethen'

makethen(readFile)('foo.txt', 'utf8')
  .then((data) => {
    // …
  })
  .catch((error) => {
    // …
  })
import request from 'request'
import makethen from 'makethen'

makethen(request)('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
  .then(([ response, body ]) => {
    // …
  })
  .catch((error) => {
    // …
  })

About

:sparkles: Promisify Node.js-style callbacks with native Promise

License:MIT License


Languages

Language:TypeScript 100.0%