Skip to content

Commit

Permalink
Improve evaldata-prune scriptlet
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Feb 20, 2025
1 parent c778f33 commit 9bb1a2b
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/js/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -1472,21 +1472,19 @@ builtinScriptlets.push({
fn: evaldataPrune,
dependencies: [
'object-prune.fn',
'proxy-apply.fn',
],
});
function evaldataPrune(
rawPrunePaths = '',
rawNeedlePaths = ''
) {
self.eval = new Proxy(self.eval, {
apply(target, thisArg, args) {
const before = Reflect.apply(target, thisArg, args);
if ( typeof before === 'object' ) {
const after = objectPruneFn(before, rawPrunePaths, rawNeedlePaths);
return after || before;
}
return before;
}
proxyApplyFn('eval', function(context) {
const before = context.reflect();
if ( typeof before !== 'object' ) { return before; }
if ( before === null ) { return null; }
const after = objectPruneFn(before, rawPrunePaths, rawNeedlePaths);
return after || before;
});
}

Expand Down

0 comments on commit 9bb1a2b

Please sign in to comment.