.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / cosmiconfig / dist / funcRunner.js
diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/cosmiconfig/dist/funcRunner.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/cosmiconfig/dist/funcRunner.js
new file mode 100644 (file)
index 0000000..0da9496
--- /dev/null
@@ -0,0 +1,22 @@
+//      
+'use strict';
+
+const chainFuncsAsync = (result, func) => result.then(func);
+const chainFuncsSync = (result, func) => func(result);
+
+/**
+ * Runs the given functions sequentially. If the `init` param is a promise,
+ * functions are chained using `p.then()`. Otherwise, functions are chained by passing
+ * the result of each function to the next.
+ */
+module.exports = function funcRunner(
+  init                ,
+  funcs                 
+)                 {
+  const isAsync = init instanceof Promise;
+
+  return funcs.reduce(
+    isAsync === true ? chainFuncsAsync : chainFuncsSync,
+    init
+  );
+};