-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
32 lines (30 loc) · 967 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*!
* always-promise <https://github.com/hybridables/always-promise>
*
* Copyright (c) 2015 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)
* Released under the MIT license.
*/
'use strict'
/**
* > Promisify everything!
*
* **Example**
*
* ```js
* const promisify = require('always-promise')
* ```
*
* @name alwaysPromise
* @param {Function|GeneratorFunction|Stream|Promise} `<val>` anything that [merz](https://github.com/hybridables/merz) accepts
* @param {Function} `[Prome]` custom promise module, which will be used for promisify-ing
* @return {Function} which returns promise
* @api public
*/
module.exports = function alwaysPromise (val, Prome) {
var self = this
return function promisified () {
var func = require('merz').call(self || this, val)
var PromiseCtor = Prome || alwaysPromise.promise || promisified.promise
return require('redolent')(func, PromiseCtor).apply(self || this, arguments)
}
}