diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:43:05 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 22:18:30 +0800 |
| commit | 89e95b3f143682ed9a006991bacf45c9dcba4818 (patch) | |
| tree | 4f44cf41b828577d583890bdd5a1c31e8491a6ba /node_modules/reduce-function-call/index.js | |
| parent | aa7f0199255277949790b41c56e8ec97dd4f0da4 (diff) | |
| download | xmake-docs-vuepress.tar.gz xmake-docs-vuepress.zip | |
remove node_modulesvuepress
Diffstat (limited to 'node_modules/reduce-function-call/index.js')
| -rwxr-xr-x | node_modules/reduce-function-call/index.js | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/node_modules/reduce-function-call/index.js b/node_modules/reduce-function-call/index.js deleted file mode 100755 index c20effaa..00000000 --- a/node_modules/reduce-function-call/index.js +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Module dependencies - */ -var balanced = require("balanced-match") - -/** - * Expose `reduceFunctionCall` - * - * @type {Function} - */ -module.exports = reduceFunctionCall - -/** - * Walkthrough all expressions, evaluate them and insert them into the declaration - * - * @param {Array} expressions - * @param {Object} declaration - */ - -function reduceFunctionCall(string, functionRE, callback) { - var call = string - return getFunctionCalls(string, functionRE).reduce(function(string, obj) { - return string.replace(obj.functionIdentifier + "(" + obj.matches.body + ")", evalFunctionCall(obj.matches.body, obj.functionIdentifier, callback, call, functionRE)) - }, string) -} - -/** - * Parses expressions in a value - * - * @param {String} value - * @returns {Array} - * @api private - */ - -function getFunctionCalls(call, functionRE) { - var expressions = [] - - var fnRE = typeof functionRE === "string" ? new RegExp("\\b(" + functionRE + ")\\(") : functionRE - do { - var searchMatch = fnRE.exec(call) - if (!searchMatch) { - return expressions - } - if (searchMatch[1] === undefined) { - throw new Error("Missing the first couple of parenthesis to get the function identifier in " + functionRE) - } - var fn = searchMatch[1] - var startIndex = searchMatch.index - var matches = balanced("(", ")", call.substring(startIndex)) - - if (!matches || matches.start !== searchMatch[0].length - 1) { - throw new SyntaxError(fn + "(): missing closing ')' in the value '" + call + "'") - } - - expressions.push({matches: matches, functionIdentifier: fn}) - call = matches.post - } - while (fnRE.test(call)) - - return expressions -} - -/** - * Evaluates an expression - * - * @param {String} expression - * @returns {String} - * @api private - */ - -function evalFunctionCall (string, functionIdentifier, callback, call, functionRE) { - // allow recursivity - return callback(reduceFunctionCall(string, functionRE, callback), functionIdentifier, call) -} |
