.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / cosmiconfig / dist / funcRunner.js
1 //      
2 'use strict';
3
4 const chainFuncsAsync = (result, func) => result.then(func);
5 const chainFuncsSync = (result, func) => func(result);
6
7 /**
8  * Runs the given functions sequentially. If the `init` param is a promise,
9  * functions are chained using `p.then()`. Otherwise, functions are chained by passing
10  * the result of each function to the next.
11  */
12 module.exports = function funcRunner(
13   init                ,
14   funcs                 
15 )                 {
16   const isAsync = init instanceof Promise;
17
18   return funcs.reduce(
19     isAsync === true ? chainFuncsAsync : chainFuncsSync,
20     init
21   );
22 };