1.0.2 • Published 9 years ago

cb2pro v1.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
9 years ago

用来将普通的回调函数转换为Promise

  • 我们约定最后一个参数为回调函数
npm i cb2pro
var fs = require('fs')
var cb2promise = require('cb2pro')

var newFs = cb2promise(fs, {}, ['readFile', 'writeFile'])

newFs.writeFile('./message.md', 'hello jarvis').then(err => {
  err ? console.error(err) : console.log('success')
})

newFs.readFile('./message.md').then((data) => {
  console.log(data.toString())
})
1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago