Parsing is expensive, if the parse tree can be stored on the DB it can save a lot of compute time, but mongo can't store Classes, so we re-write without classes
21 lines
360 B
JavaScript
21 lines
360 B
JavaScript
export default class Context {
|
|
constructor({errors = [], rolls = []}){
|
|
this.errors = errors;
|
|
this.rolls = rolls;
|
|
}
|
|
error(e){
|
|
if (!e) return;
|
|
if (typeof e === 'string'){
|
|
this.errors.push({
|
|
type: 'error',
|
|
message: e,
|
|
});
|
|
} else {
|
|
this.errors.push(e);
|
|
}
|
|
}
|
|
roll(r){
|
|
this.rolls.push(r);
|
|
}
|
|
}
|