You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
may break in old envs. calling redolent() now throws if no promise found by the native-or-another
detection - before it was throwing from the promisified function, now it throws earlier
Will try to promisify `fn` with native Promise, otherwise you can give different promise module to `opts.Promise`, for example [pinkie][] or [bluebird][]. If `fn`[is-async-function][] it will be passed with `done` callback as last argument - always concatenated with the other provided args through `opts.args`.
54
54
55
+
_**Note:** Uses [native-or-another][] for detection, so it will always will use the
56
+
native Promise, otherwise will try to load some of the common promise libraries
57
+
and as last resort if can't find one of them installed, then throws an Error!_
58
+
**Tip:** You can use `require('native-or-another/register')` instead of passing
59
+
a promise to `opts.Promise`, it exposes a function that accepts same
60
+
options object, `{ Promise: MyPromise }` for example.
61
+
55
62
**Params**
56
63
57
64
*`<fn>`**{Function}**: a function to be promisified
58
-
*`[opts]`**{Object}**: optional options - like `.args`, `.context`, `.Promise`
65
+
*`[opts]`**{Object}**: optional options, also passed to [native-or-another][]
59
66
*`[opts.args]`**{Array}**: additional arguments to be passed to `fn`, all args from `opts.args` and these that are passed to promisifed function are concatenated
60
67
*`[opts.context]`**{Object}**: what context to be applied to `fn`, by default it is smart enough and applies the `this` context of redolent call or the call of the promisified function
61
-
*`[opts.Promise]`**{Function}**: custom Promise constructor function, like [bluebird][] for example, by default uses the native Promise
68
+
*`[opts.Promise]`**{Function}**: custom Promise constructor for versions `< v0.12`, like [bluebird][] for example, by default it **always** uses the native Promise in newer node versions
69
+
*`[opts.global]`**{Boolean}**: defaults to `true`, pass false if you don't want to attach/add/register the given promise to the `global` scope, when node `< v0.12`
-[always-promise](https://www.npmjs.com/package/always-promise): Promisify, basically, everything. Generator function, callback-style or synchronous function; sync function that returns child process, stream or observable; directly passed… [more](https://github.com/hybridables/always-promise#readme) | [homepage](https://github.com/hybridables/always-promise#readme"Promisify, basically, everything. Generator function, callback-style or synchronous function; sync function that returns child process, stream or observable; directly passed promise, stream or child process.")
120
128
-[always-thunk](https://www.npmjs.com/package/always-thunk): Create thunk from async or sync function. Works like `thunkify`. | [homepage](https://github.com/tunnckocore/always-thunk#readme"Create thunk from async or sync function. Works like `thunkify`.")
121
129
-[arr-includes](https://www.npmjs.com/package/arr-includes): Return positive value if any of passed values exists in array, or optionally an index. | [homepage](https://github.com/tunnckocore/arr-includes#readme"Return positive value if any of passed values exists in array, or optionally an index.")
-[dush](https://www.npmjs.com/package/dush): Microscopic & functional event emitter in ~260 bytes, extensible through plugins. | [homepage](https://github.com/tunnckocore/dush#readme"Microscopic & functional event emitter in ~260 bytes, extensible through plugins.")
123
131
-[letta](https://www.npmjs.com/package/letta): Promisify sync, async or generator function, using [relike][]. Kind of promisify, but lower level. Full compatibility with [co][]4 and passing… [more](https://github.com/hybridables/letta#readme) | [homepage](https://github.com/hybridables/letta#readme"Promisify sync, async or generator function, using [relike][]. Kind of promisify, but lower level. Full compatibility with [co][]4 and passing 100% of its tests.")
124
132
-[minibase](https://www.npmjs.com/package/minibase): Minimalist alternative for Base. Build complex APIs with small units called plugins. Works well with most of the already existing… [more](https://github.com/node-minibase/minibase#readme) | [homepage](https://github.com/node-minibase/minibase#readme"Minimalist alternative for Base. Build complex APIs with small units called plugins. Works well with most of the already existing [base][] plugins.")
125
133
-[native-promise](https://www.npmjs.com/package/native-promise): Get native `Promise` or falsey value if not available. | [homepage](https://github.com/tunnckocore/native-promise#readme"Get native `Promise` or falsey value if not available.")
0 commit comments