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;
|
||||
}
|
||||
|
||||
static contextDefaults() {
|
||||
return {
|
||||
console,
|
||||
Math,
|
||||
wait: (ms) => new Promise((resolve) => { setTimeout(resolve, ms); }),
|
||||
};
|
||||
}
|
||||
|
||||
static createContext(locals = {}) {
|
||||
if (locals[Populated]) {
|
||||
return locals;
|
||||
}
|
||||
return {
|
||||
[Populated]: true,
|
||||
...this.contextDefaults(),
|
||||
...locals,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user