feat: script context defaults
This commit is contained in:
parent
fbbd74f778
commit
df5d55a0ac
|
@ -29,12 +29,21 @@ export default class Script {
|
||||||
return this.sandbox.context;
|
return this.sandbox.context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static contextDefaults() {
|
||||||
|
return {
|
||||||
|
console,
|
||||||
|
Math,
|
||||||
|
wait: (ms) => new Promise((resolve) => { setTimeout(resolve, ms); }),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static createContext(locals = {}) {
|
static createContext(locals = {}) {
|
||||||
if (locals[Populated]) {
|
if (locals[Populated]) {
|
||||||
return locals;
|
return locals;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
[Populated]: true,
|
[Populated]: true,
|
||||||
|
...this.contextDefaults(),
|
||||||
...locals,
|
...locals,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user