From e04dfd26bcf97a6ef2fc7fb6a5fb881d6b070699 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Tue, 17 Mar 2015 18:30:26 +0100 Subject: [PATCH] Rename customFuncions to callbacks --- lib/expression/node/ArrayNode.js | 6 +++--- lib/expression/node/AssignmentNode.js | 4 ++-- lib/expression/node/BlockNode.js | 4 ++-- lib/expression/node/ConditionalNode.js | 8 ++++---- lib/expression/node/ConstantNode.js | 2 +- lib/expression/node/FunctionAssignmentNode.js | 4 ++-- lib/expression/node/FunctionNode.js | 4 ++-- lib/expression/node/IndexNode.js | 4 ++-- lib/expression/node/OperatorNode.js | 10 +++++----- lib/expression/node/RangeNode.js | 8 ++++---- lib/expression/node/SymbolNode.js | 4 ++-- lib/expression/node/UpdateNode.js | 4 ++-- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/expression/node/ArrayNode.js b/lib/expression/node/ArrayNode.js index f8d99bbaf..c4636c06c 100644 --- a/lib/expression/node/ArrayNode.js +++ b/lib/expression/node/ArrayNode.js @@ -99,18 +99,18 @@ ArrayNode.prototype.toString = function() { * @param {String} type * @return {String} str */ -ArrayNode.prototype._toTex = function(customFunctions) { +ArrayNode.prototype._toTex = function(callbacks) { this.latexType = this.latexType || 'bmatrix'; var s = '\\begin{' + this.latexType + '}'; this.nodes.forEach(function(node) { if (node.nodes) { s += node.nodes.map(function(childNode) { - return childNode.toTex(customFunctions); + return childNode.toTex(callbacks); }).join('&'); } else { - s += node.toTex(customFunctions); + s += node.toTex(callbacks); } // new line diff --git a/lib/expression/node/AssignmentNode.js b/lib/expression/node/AssignmentNode.js index ce9da5cfc..e47e22349 100644 --- a/lib/expression/node/AssignmentNode.js +++ b/lib/expression/node/AssignmentNode.js @@ -92,11 +92,11 @@ AssignmentNode.prototype.toString = function() { * @param {Object|function} callback(s) * @return {String} */ -AssignmentNode.prototype._toTex = function(customFunctions) { +AssignmentNode.prototype._toTex = function(callbacks) { var precedence = operators.getPrecedence(this); var exprPrecedence = operators.getPrecedence(this.expr); - var expr = this.expr.toTex(customFunctions); + var expr = this.expr.toTex(callbacks); if ((exprPrecedence !== null) && (exprPrecedence <= precedence)) { //adds visible round brackets expr = latex.addBraces(expr, true); diff --git a/lib/expression/node/BlockNode.js b/lib/expression/node/BlockNode.js index 90b2d1a14..3bccddbd1 100644 --- a/lib/expression/node/BlockNode.js +++ b/lib/expression/node/BlockNode.js @@ -125,9 +125,9 @@ BlockNode.prototype.toString = function() { * @param {Object|function} callback(s) * @return {String} str */ -BlockNode.prototype._toTex = function(customFunctions) { +BlockNode.prototype._toTex = function(callbacks) { return this.blocks.map(function (param) { - return param.node.toTex(customFunctions) + (param.visible ? '' : ';'); + return param.node.toTex(callbacks) + (param.visible ? '' : ';'); }).join('\n'); }; diff --git a/lib/expression/node/ConditionalNode.js b/lib/expression/node/ConditionalNode.js index 29f4c9ff3..e5acb04a5 100644 --- a/lib/expression/node/ConditionalNode.js +++ b/lib/expression/node/ConditionalNode.js @@ -154,13 +154,13 @@ ConditionalNode.prototype.toString = function() { * @param {Object|function} callback(s) * @return {String} str */ -ConditionalNode.prototype._toTex = function(customFunctions) { +ConditionalNode.prototype._toTex = function(callbacks) { var s = ( - latex.addBraces(this.trueExpr.toTex(customFunctions)) + + latex.addBraces(this.trueExpr.toTex(callbacks)) + ', &\\quad' + - latex.addBraces('\\text{if}\\;' + this.condition.toTex(customFunctions)) + latex.addBraces('\\text{if}\\;' + this.condition.toTex(callbacks)) ) + '\\\\' + ( - latex.addBraces(this.falseExpr.toTex(customFunctions)) + + latex.addBraces(this.falseExpr.toTex(callbacks)) + ', &\\quad' + latex.addBraces('\\text{otherwise}') ); diff --git a/lib/expression/node/ConstantNode.js b/lib/expression/node/ConstantNode.js index dd001315e..10e8448cf 100644 --- a/lib/expression/node/ConstantNode.js +++ b/lib/expression/node/ConstantNode.js @@ -159,7 +159,7 @@ ConstantNode.prototype.toString = function() { * @param {Object|function} callback(s) * @return {String} str */ -ConstantNode.prototype._toTex = function(customFunctions) { +ConstantNode.prototype._toTex = function(callbacks) { var value = this.value, index; switch (this.valueType) { diff --git a/lib/expression/node/FunctionAssignmentNode.js b/lib/expression/node/FunctionAssignmentNode.js index 5718c0908..03fe8f43d 100644 --- a/lib/expression/node/FunctionAssignmentNode.js +++ b/lib/expression/node/FunctionAssignmentNode.js @@ -113,11 +113,11 @@ FunctionAssignmentNode.prototype.toString = function() { * @param {Object|function} callback(s) * @return {String} str */ -FunctionAssignmentNode.prototype._toTex = function(customFunctions) { +FunctionAssignmentNode.prototype._toTex = function(callbacks) { var precedence = operators.getPrecedence(this); var exprPrecedence = operators.getPrecedence(this.expr); - var expr = this.expr.toTex(customFunctions); + var expr = this.expr.toTex(callbacks); if ((exprPrecedence !== null) && (exprPrecedence <= precedence)) { //adds visible round brackets expr = latex.addBraces(expr, true); diff --git a/lib/expression/node/FunctionNode.js b/lib/expression/node/FunctionNode.js index eaeee60d2..fcce31025 100644 --- a/lib/expression/node/FunctionNode.js +++ b/lib/expression/node/FunctionNode.js @@ -116,8 +116,8 @@ FunctionNode.prototype.toString = function() { * @param {Object|function} callback(s) * @return {String} str */ -FunctionNode.prototype._toTex = function(customFunctions) { - return latex.toArgs(this, customFunctions); +FunctionNode.prototype._toTex = function(callbacks) { + return latex.toArgs(this, callbacks); }; /** diff --git a/lib/expression/node/IndexNode.js b/lib/expression/node/IndexNode.js index 175826630..ed12171f7 100644 --- a/lib/expression/node/IndexNode.js +++ b/lib/expression/node/IndexNode.js @@ -212,8 +212,8 @@ IndexNode.prototype.toString = function() { * @param {Object|function} callback(s) * @return {String} str */ -IndexNode.prototype._toTex = function(customFunctions) { - return this.object.toTex(customFunctions) + '[' + this.ranges.join(', ') + ']'; +IndexNode.prototype._toTex = function(callbacks) { + return this.object.toTex(callbacks) + '[' + this.ranges.join(', ') + ']'; }; module.exports = IndexNode; diff --git a/lib/expression/node/OperatorNode.js b/lib/expression/node/OperatorNode.js index 986fed1af..ee8db2afa 100644 --- a/lib/expression/node/OperatorNode.js +++ b/lib/expression/node/OperatorNode.js @@ -239,7 +239,7 @@ OperatorNode.prototype.toString = function() { * @param {Object|function} callback(s) * @return {String} str */ -OperatorNode.prototype._toTex = function(customFunctions) { +OperatorNode.prototype._toTex = function(callbacks) { var args = this.args; var parens = calculateNecessaryParentheses(this, args); var op = latex.toOperator(this.op); //operator @@ -248,7 +248,7 @@ OperatorNode.prototype._toTex = function(customFunctions) { case 1: //unary operators var assoc = operators.getAssociativity(this); - var operand = args[0].toTex(customFunctions); + var operand = args[0].toTex(callbacks); if (parens[0]) { operand = latex.addBraces(operand, true); } @@ -266,9 +266,9 @@ OperatorNode.prototype._toTex = function(customFunctions) { case 2: //binary operators var lhs = args[0]; //left hand side //reminder: if parens[0] is false, this puts it in curly braces - var lhsTex = latex.addBraces(lhs.toTex(customFunctions), parens[0]); + var lhsTex = latex.addBraces(lhs.toTex(callbacks), parens[0]); var rhs = args[1]; //right hand side - var rhsTex = latex.addBraces(rhs.toTex(customFunctions), parens[1]); + var rhsTex = latex.addBraces(rhs.toTex(callbacks), parens[1]); switch (this.getIdentifier()) { case 'OperatorNode:divide': @@ -276,7 +276,7 @@ OperatorNode.prototype._toTex = function(customFunctions) { return op + lhsTex + rhsTex; case 'OperatorNode:to': - rhsTex = latex.toUnit(rhs.toTex(customFunctions)); + rhsTex = latex.toUnit(rhs.toTex(callbacks)); rhsTex = latex.addBraces(rhsTex, parens[1]); break; } diff --git a/lib/expression/node/RangeNode.js b/lib/expression/node/RangeNode.js index f28cfc156..d3af794ee 100644 --- a/lib/expression/node/RangeNode.js +++ b/lib/expression/node/RangeNode.js @@ -124,12 +124,12 @@ RangeNode.prototype.toString = function() { * @params {Object|function} callback(s) * @return {String} str */ -RangeNode.prototype._toTex = function(customFunctions) { - var str = this.start.toTex(customFunctions); +RangeNode.prototype._toTex = function(callbacks) { + var str = this.start.toTex(callbacks); if (this.step) { - str += ':' + this.step.toTex(customFunctions); + str += ':' + this.step.toTex(callbacks); } - str += ':' + this.end.toTex(customFunctions); + str += ':' + this.end.toTex(callbacks); return str; }; diff --git a/lib/expression/node/SymbolNode.js b/lib/expression/node/SymbolNode.js index 34409fe80..6d807d31d 100644 --- a/lib/expression/node/SymbolNode.js +++ b/lib/expression/node/SymbolNode.js @@ -103,8 +103,8 @@ SymbolNode.prototype.toString = function() { * @return {String} str * @override */ -SymbolNode.prototype._toTex = function(customFunctions) { - return latex.toSymbol(this.name, customFunctions); +SymbolNode.prototype._toTex = function(callbacks) { + return latex.toSymbol(this.name, callbacks); }; module.exports = SymbolNode; diff --git a/lib/expression/node/UpdateNode.js b/lib/expression/node/UpdateNode.js index 346504ff6..323ad1f12 100644 --- a/lib/expression/node/UpdateNode.js +++ b/lib/expression/node/UpdateNode.js @@ -87,8 +87,8 @@ UpdateNode.prototype.toString = function() { * @param {Object|function} callback(s) * @return {String} */ -UpdateNode.prototype._toTex = function(customFunctions) { - return this.index.toTex(customFunctions) + ' = ' + this.expr.toTex(customFunctions); +UpdateNode.prototype._toTex = function(callbacks) { + return this.index.toTex(callbacks) + ' = ' + this.expr.toTex(callbacks); }; module.exports = UpdateNode;