Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3ac076d

Browse files
committed
Load limits from /common/config
1 parent 148c3c9 commit 3ac076d

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## [2.0.4]
10+
### Fixed
11+
- Load limits from /common/config
12+
913
## [2.0.3]
1014
### Fixed
1115
- Handle unhandled promise rejections
@@ -26,4 +30,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2630
- Tracers for Java and C++.
2731

2832
### Changed
29-
- Almost every method has been changed. Take a look at [Tracer API](https://github.com/algorithm-visualizer/tracers/wiki).
33+
- Almost every method has been changed. Take a look at [Tracer API](https://github.com/algorithm-visualizer/tracers/wiki).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@algorithm-visualizer/tracer-generator",
3-
"version": "2.0.3",
3+
"version": "2.0.4",
44
"description": "Visualization Libraries for Algorithm Visualizer",
55
"scripts": {
66
"build": "node ./node_modules/webpack/bin/webpack --bail --progress --config webpack.config.js && chmod +x ./bin/*"

src/common/config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
export {};
1+
const maxTraces = 1e6;
2+
const maxTracers = 1e2;
3+
4+
export {
5+
maxTraces,
6+
maxTracers,
7+
};

src/languages/Exeuter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { execute } from '/common/util';
22
import Commander from '/languages/Commander';
3+
import { maxTracers, maxTraces } from '/common/config';
34

45
class Executer extends Commander {
56
constructor({ name, compileCommand, runCommand }) {
@@ -17,7 +18,7 @@ class Executer extends Commander {
1718
'-w=/usr/judge',
1819
`-v=$PWD/tracers:/usr/bin/tracers:ro`,
1920
`-v=${tempPath}:/usr/judge:rw`,
20-
`-e MAX_TRACES=${1e6} -e MAX_TRACERS=${1e2}`, // TODO: load from /common/config
21+
`-e MAX_TRACES=${maxTraces} -e MAX_TRACERS=${maxTracers}`,
2122
this.executerImageTag,
2223
'/bin/bash -c',
2324
`"${command}"`,

src/languages/js/tracers/src/Tracer.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
const MAX_TRACES = 1e6;
2-
const MAX_TRACERS = 1e2;
1+
import { maxTraces, maxTracers } from '../../../../common/config';
32

43
class Tracer {
54
static addTracer(className, title) {
@@ -17,8 +16,8 @@ class Tracer {
1716
args: JSON.parse(JSON.stringify(args)),
1817
};
1918
this.traces.push(trace);
20-
if (this.traces.length > MAX_TRACES) throw new Error('Traces Limit Exceeded');
21-
if (this.tracerCount > MAX_TRACERS) throw new Error('Tracers Limit Exceeded');
19+
if (this.traces.length > maxTraces) throw new Error('Traces Limit Exceeded');
20+
if (this.tracerCount > maxTracers) throw new Error('Tracers Limit Exceeded');
2221
}
2322

2423
constructor(title = this.constructor.name) {

0 commit comments

Comments
 (0)