Skip to content

Commit b3edc4e

Browse files
author
tunnckoCore
committed
fix(deps): switch to use "native-or-another"
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
1 parent 1330ad0 commit b3edc4e

File tree

7 files changed

+3021
-165
lines changed

7 files changed

+3021
-165
lines changed

Diff for: README.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,24 @@ const redolent = require('redolent')
4949

5050
## API
5151

52-
### [redolent](index.js#L71)
52+
### [redolent](index.js#L86)
5353
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`.
5454

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+
5562
**Params**
5663

5764
* `<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][]
5966
* `[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
6067
* `[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`
6270
* `returns` **{Function}**: promisified function
6371

6472
**Example**
@@ -119,7 +127,7 @@ console.log(promise.___nativePromise) // => false
119127
- [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.")
120128
- [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`.")
121129
- [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.")
122-
- [dush](https://www.npmjs.com/package/dush): Microscopic & functional event emitter | [homepage](https://github.com/tunnckocore/dush#readme "Microscopic & functional event emitter")
130+
- [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.")
123131
- [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.")
124132
- [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.")
125133
- [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.")
@@ -168,7 +176,7 @@ Copyright © 2015, 2017, [Charlike Mike Reagent](https://i.am.charlike.online).
168176

169177
***
170178

171-
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on March 11, 2017._
179+
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on March 17, 2017._
172180
_Project scaffolded using [charlike][] cli._
173181

174182
[always-done]: https://github.com/hybridables/always-done
@@ -214,3 +222,4 @@ _Project scaffolded using [charlike][] cli._
214222
[paypalme-url]: https://www.paypal.me/tunnckoCore
215223
[paypalme-img]: https://img.shields.io/badge/paypal-donate-brightgreen.svg
216224

225+
[native-or-another]: https://github.com/tunnckocore/native-or-another

0 commit comments

Comments
 (0)