Skip to content

Commit

Permalink
fix: types made optional
Browse files Browse the repository at this point in the history
fix #84
  • Loading branch information
bugwheels94 committed Feb 5, 2024
1 parent 9d05bb1 commit dc92595
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { createMathFunctions } from './functions'
// var Mexp = function (parsed) {
// this.value = parsed
// }

class Mexp {
static TOKEN_TYPES = tokenTypes
static tokenTypes = tokenTypes
Expand All @@ -16,7 +15,7 @@ class Mexp {
addToken = addToken
lex = lex
postfixEval = postfixEval
eval(string: string, tokens: Token[], Constants: Constants) {
eval(string: string, tokens?: Token[], Constants?: Constants) {
return this.postfixEval(this.toPostfix(this.lex(string, tokens)), Constants)
}
math!: ReturnType<typeof createMathFunctions>
Expand Down
2 changes: 1 addition & 1 deletion src/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function tokenize(mexp: Mexp, string: string) {
}
return nodes;
}
export const lex = function (this: Mexp, inp: string, tokens: Token[]) {
export const lex = function (this: Mexp, inp: string, tokens?: Token[]) {
"use strict";
var changeSignObj: ParsedToken = {
value: this.math.changeSign,
Expand Down
2 changes: 1 addition & 1 deletion src/postfix_evaluator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { toPostfix } from './postfix'
import { tokenTypes, ParsedToken } from './token'
export type Constants = Record<string, number>
export function postfixEval(arr: ReturnType<typeof toPostfix>, Constants: Constants) {
export function postfixEval(arr: ReturnType<typeof toPostfix>, Constants?: Constants) {
Constants = Constants || {}
Constants.PI = Math.PI
Constants.E = Math.E
Expand Down

0 comments on commit dc92595

Please sign in to comment.