lib/utils/promises.js
function (module, opts) {
        var config = opts || {},
            isValid = config.isValid || function (f, fn, mod) {
                    /**
                     * Filter out functions that aren't 'public' and aren't 'methods' and aren't asynchronous.
                     *  This is mostly educated guess work based on de facto naming standards for js.
                     *
                     * e.g.
                     *      valid:        'someFunctionName' or 'some_function_name' or 'someFunctionAsync'
                     *      not valid:    'SomeConstructor' or '_someFunctionName' or 'someFunctionSync'
                     *
                     *  As there may be exceptions to these rules for certain modules,
                     *   you can pass in a function via opts.isValid which will override this.
                     */
                    return typeof f === 'function' && fn[0] !== '_' && fn[0].toUpperCase() !== fn[0] && !fn.endsWith('Sync');
                };

        return utils.mapObject(module, function (f, fn, mod) {
            return utils.promisify(mod, fn);
        }, isValid);
    }
function (module, opts) {
        var config = opts || {},
            isValid = config.isValid || function (f, fn, mod) {
                    /**
                     * Filter out functions that aren't 'public' and aren't 'methods' and aren't asynchronous.
                     *  This is mostly educated guess work based on de facto naming standards for js.
                     *
                     * e.g.
                     *      valid:        'someFunctionName' or 'some_function_name' or 'someFunctionAsync'
                     *      not valid:    'SomeConstructor' or '_someFunctionName' or 'someFunctionSync'
                     *
                     *  As there may be exceptions to these rules for certain modules,
                     *   you can pass in a function via opts.isValid which will override this.
                     */
                    return typeof f === 'function' && fn[0] !== '_' && fn[0].toUpperCase() !== fn[0] && !fn.endsWith('Sync');
                };

        return utils.mapObject(module, function (f, fn, mod) {
            return utils.promisify(mod, fn);
        }, isValid);
    }
Calls promisify on all valid functions on a module.
Ignores certain properties on a modules so the return values is not polluted.
(This can be configured by passing in a filter function via opts.isValid.)

E.g.    var myFs = promisifyAll(fs),
myFs.readdir('somedir').then(doSomething);

@param module
@param opts
@returns