Strip one level of indirection from functions module exports

This commit is contained in:
Martin von Gagern 2015-09-10 09:22:24 +02:00
parent 8accf0f18a
commit 5539226f4b
2 changed files with 7 additions and 9 deletions

View File

@ -173,7 +173,7 @@ Parser.prototype.handleInfixNodes = function (body, mode) {
} }
overIndex = i; overIndex = i;
funcName = node.value.replaceWith; funcName = node.value.replaceWith;
func = functions.funcs[funcName]; func = functions[funcName];
} }
} }
@ -225,7 +225,7 @@ Parser.prototype.handleSupSubscript = function(pos, mode, symbol, name) {
} else if (group.isFunction) { } else if (group.isFunction) {
// ^ and _ have a greediness, so handle interactions with functions' // ^ and _ have a greediness, so handle interactions with functions'
// greediness // greediness
var funcGreediness = functions.funcs[group.result.result].greediness; var funcGreediness = functions[group.result.result].greediness;
if (funcGreediness > SUPSUB_GREEDINESS) { if (funcGreediness > SUPSUB_GREEDINESS) {
return this.parseFunction(pos, mode); return this.parseFunction(pos, mode);
} else { } else {
@ -484,7 +484,7 @@ Parser.prototype.parseFunction = function(pos, mode) {
if (baseGroup) { if (baseGroup) {
if (baseGroup.isFunction) { if (baseGroup.isFunction) {
var func = baseGroup.result.result; var func = baseGroup.result.result;
var funcData = functions.funcs[func]; var funcData = functions[func];
if (mode === "text" && !funcData.allowedInText) { if (mode === "text" && !funcData.allowedInText) {
throw new ParseError( throw new ParseError(
"Can't use function '" + func + "' in text mode", "Can't use function '" + func + "' in text mode",
@ -494,7 +494,7 @@ Parser.prototype.parseFunction = function(pos, mode) {
var args = [func]; var args = [func];
var newPos = this.parseArguments( var newPos = this.parseArguments(
baseGroup.result.position, mode, func, funcData, args); baseGroup.result.position, mode, func, funcData, args);
var result = functions.funcs[func].handler.apply(this, args); var result = functions[func].handler.apply(this, args);
return new ParseResult( return new ParseResult(
new ParseNode(result.type, result, mode), new ParseNode(result.type, result, mode),
newPos); newPos);
@ -563,7 +563,7 @@ Parser.prototype.parseArguments = function(pos, mode, func, funcData, args) {
var argNode; var argNode;
if (arg.isFunction) { if (arg.isFunction) {
var argGreediness = var argGreediness =
functions.funcs[arg.result.result].greediness; functions[arg.result.result].greediness;
if (argGreediness > baseGreediness) { if (argGreediness > baseGreediness) {
argNode = this.parseFunction(newPos, mode); argNode = this.parseFunction(newPos, mode);
} else { } else {
@ -695,7 +695,7 @@ Parser.prototype.parseOptionalGroup = function(pos, mode) {
Parser.prototype.parseSymbol = function(pos, mode) { Parser.prototype.parseSymbol = function(pos, mode) {
var nucleus = this.lexer.lex(pos, mode); var nucleus = this.lexer.lex(pos, mode);
if (functions.funcs[nucleus.text]) { if (functions[nucleus.text]) {
// If there exists a function with this name, we return the function and // If there exists a function with this name, we return the function and
// say that it is a function. // say that it is a function.
return new ParseFuncOrArgument( return new ParseFuncOrArgument(

View File

@ -624,6 +624,4 @@ for (var f in functions) {
} }
} }
module.exports = { module.exports = functions;
funcs: functions
};