Skip to content

Instantly share code, notes, and snippets.

@tgrecojs
Created February 21, 2024 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgrecojs/4e84757b5b34359fdfaa95b5c2f8d6ed to your computer and use it in GitHub Desktop.
Save tgrecojs/4e84757b5b34359fdfaa95b5c2f8d6ed to your computer and use it in GitHub Desktop.
const c = new Compartment({ console, Math: { log2: Math.log2 });
c.evaluate(
`
console.log('---------------')
console.group('---- inside compartment ----')
console.log('---------------')
const num = 10;
console.log('num', num);
console.log('---------------')
const result = Math.log2(num);
console.log('result', num);
console.groupEnd();
return { result }
`
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment