apache / nano

Nano is now part of Apache CouchDB. Repo moved to https://GitHub.com/apache/couchdb-nano

Home Page:https://github.com/apache/couchdb-nano

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support for promises

dgreisen-cfpb opened this issue · comments

Would you consider a PR for promise support? My initial thought for the api is that if the passed callback is the string "p", then nano will return a promise rather than a stream. This should be backwards compatible with minimal changes to the code base. If you don't pass a callback, a stream is returned as usual. If you pass a function as a callback, then the callback is called as usual. The relax function would be modified to return a promise if the callback is "p". Wherever an optional arg check is performed (e.g. https://github.com/dscape/nano/blob/master/lib/nano.js#L53), would modify the check for a "p" string callback in addition to a function callback.

Let me know if this is something that you would be interested in.

Thank you.

i think the adequate thing to do would be to create a nano-promisses module if you think this is a good idea.

people can then use it when they prefer promises to callbacks and streams

Great. Please do add a reference to the readme in case people want to use promises, they can find out how to!

Thanks for the great work

@dscape I think this should be part of the official repo. nano-promise is now outdated..