Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to support non-error-first APIs #31

Closed
sindresorhus opened this issue Sep 16, 2016 · 4 comments
Closed

Add option to support non-error-first APIs #31

sindresorhus opened this issue Sep 16, 2016 · 4 comments

Comments

@sindresorhus
Copy link
Owner

Initially, I didn't want this as it's a bad practise, so I asked @SamVerschueren to make a module.

After using pify for a good while, I've needed it more often than I would have liked, with a few Node.js API's (fs.exists), events, Chrome extension API's, and browser API's.

Instead of pretty much duplicating most of the code here into rfpify, I think we should add an option for it here instead.

@SamVerschueren Thoughts?

@SamVerschueren
Copy link
Contributor

I almost never have to use rfpify to be honest. But I'm not using as much obscure API'S as you do :p. So yes, it might be easier to add an option here.

@kevva
Copy link

kevva commented Sep 16, 2016

I almost never have to use rfpify to be honest.

Me neither. Only if I need to catch some event when testing.

@notpushkin
Copy link

WebTorrent uses this sometimes:

client.add(magnetURI, function (torrent) {  // no error parameter
  // Got torrent metadata!
  console.log('Client is downloading:', torrent.infoHash)
})

@jdalton
Copy link

jdalton commented Feb 21, 2017

Just got bit by exists. I avoided the issue with:

pify((a, b) => fs.exists(a, (c) => b(null, c)))

@sindresorhus sindresorhus changed the title Add option to support non-error first API's Add option to support non-error-first APIs Apr 18, 2017
sindresorhus added a commit that referenced this issue Apr 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants