@specialblend/unpromisify

0.0.1 • Public • Published

@specialblend/unpromisify

convert async functions into callback style functions

Install

npm install @specialblend/unpromisify

Example

import

import unpromisify from '@specialblend/unpromisify'

const checkYoSelfFoo = async name => `Hey ${name}, checkYoSelfFoo!`

const checkYoSelfBar = unpromisify(checkYoSelfFoo)

checkYoSelfFoo('@specialblend')
    .then(console.log)  // => 'Hey @specialblend, checkYoSelfFoo!'
    .catch(console.error)

checkYoSelfBar('@specialblend', (err, data) => {
    if(err) console.error(err)
    console.log(data)   // => 'Hey @specialblend, checkYoSelfFoo!'
})

require

const unpromisify = require('@specialblend/unpromisify')

function checkYoSelfFoo (name) {
	return Promise.resolve('Hey ' + name + ', checkYoSelfFoo!')
}

const checkYoSelfBar = unpromisify(checkYoSelfFoo)

checkYoSelfFoo('@specialblend')
    .then(console.log)  // => 'Hey @specialblend, checkYoSelfFoo!'
    .catch(console.error)

checkYoSelfBar('@specialblend', function (err, data) {
    if(err) console.error(err)
    console.log(data)   // => 'Hey @specialblend, checkYoSelfFoo!'
})

Package Sidebar

Install

npm i @specialblend/unpromisify

Weekly Downloads

1

Version

0.0.1

License

ISC

Unpacked Size

4.54 kB

Total Files

5

Last publish

Collaborators

  • __specialblend__