mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 06:20:02 -04:00
add try statement catching
This commit is contained in:
parent
ca1574fccc
commit
58f6a4330a
4 changed files with 40 additions and 13 deletions
|
@ -2,21 +2,21 @@ import { ScramjetClient, ProxyCtx } from "../client";
|
|||
import { rewriteJs } from "../shared";
|
||||
|
||||
function rewriteFunction(ctx: ProxyCtx) {
|
||||
const stringifiedFunction = ctx.fn(...ctx.args).toString();
|
||||
const stringifiedFunction = ctx.fn(...ctx.args).toString();
|
||||
|
||||
ctx.return(ctx.fn(`return ${rewriteJs(stringifiedFunction)}`)());
|
||||
ctx.return(ctx.fn(`return ${rewriteJs(stringifiedFunction)}`)());
|
||||
}
|
||||
|
||||
export default function (client: ScramjetClient, self: Self) {
|
||||
client.Proxy("Function", {
|
||||
apply(ctx) {
|
||||
rewriteFunction(ctx);
|
||||
},
|
||||
client.Proxy("Function", {
|
||||
apply(ctx) {
|
||||
rewriteFunction(ctx);
|
||||
},
|
||||
|
||||
construct(ctx) {
|
||||
rewriteFunction(ctx);
|
||||
},
|
||||
});
|
||||
construct(ctx) {
|
||||
rewriteFunction(ctx);
|
||||
},
|
||||
});
|
||||
|
||||
Function.prototype.constructor = Function;
|
||||
}
|
||||
Function.prototype.constructor = Function;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue