Skip to content

Commit c7f46d4

Browse files
authored
Expose initial exec time to runInContext options (#314)
1 parent 0cc01dc commit c7f46d4

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-slang",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"description": "Javascript-based interpreter for slang, written in Typescript",
55
"author": {
66
"name": "Source Academy",

src/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ export const UNKNOWN_LOCATION: es.SourceLocation = {
1515
}
1616
export const JSSLANG_PROPERTIES = {
1717
maxExecTime: 1000,
18-
originalMaxExecTime: 1000,
1918
factorToIncreaseBy: 10
2019
}

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ export interface IOptions {
3131
scheduler: 'preemptive' | 'async'
3232
steps: number
3333
executionMethod: ExecutionMethod
34+
originalMaxExecTime: number
3435
}
3536

3637
const DEFAULT_OPTIONS: IOptions = {
3738
scheduler: 'async',
3839
steps: 1000,
39-
executionMethod: 'auto'
40+
executionMethod: 'auto',
41+
originalMaxExecTime: 1000
4042
}
4143

4244
// needed to work on browsers
@@ -162,7 +164,7 @@ export function runInContext(
162164
if (previousCode === code) {
163165
JSSLANG_PROPERTIES.maxExecTime *= JSSLANG_PROPERTIES.factorToIncreaseBy
164166
} else {
165-
JSSLANG_PROPERTIES.maxExecTime = JSSLANG_PROPERTIES.originalMaxExecTime
167+
JSSLANG_PROPERTIES.maxExecTime = theOptions.originalMaxExecTime
166168
}
167169
previousCode = code
168170
let transpiled

0 commit comments

Comments
 (0)