Skip to content

Commit dc92595

Browse files
committed
fix: types made optional
fix #84
1 parent 9d05bb1 commit dc92595

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

src/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { createMathFunctions } from './functions'
77
// var Mexp = function (parsed) {
88
// this.value = parsed
99
// }
10-
1110
class Mexp {
1211
static TOKEN_TYPES = tokenTypes
1312
static tokenTypes = tokenTypes
@@ -16,7 +15,7 @@ class Mexp {
1615
addToken = addToken
1716
lex = lex
1817
postfixEval = postfixEval
19-
eval(string: string, tokens: Token[], Constants: Constants) {
18+
eval(string: string, tokens?: Token[], Constants?: Constants) {
2019
return this.postfixEval(this.toPostfix(this.lex(string, tokens)), Constants)
2120
}
2221
math!: ReturnType<typeof createMathFunctions>

src/lexer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function tokenize(mexp: Mexp, string: string) {
195195
}
196196
return nodes;
197197
}
198-
export const lex = function (this: Mexp, inp: string, tokens: Token[]) {
198+
export const lex = function (this: Mexp, inp: string, tokens?: Token[]) {
199199
"use strict";
200200
var changeSignObj: ParsedToken = {
201201
value: this.math.changeSign,

src/postfix_evaluator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { toPostfix } from './postfix'
22
import { tokenTypes, ParsedToken } from './token'
33
export type Constants = Record<string, number>
4-
export function postfixEval(arr: ReturnType<typeof toPostfix>, Constants: Constants) {
4+
export function postfixEval(arr: ReturnType<typeof toPostfix>, Constants?: Constants) {
55
Constants = Constants || {}
66
Constants.PI = Math.PI
77
Constants.E = Math.E

0 commit comments

Comments
 (0)