Skip to main content

Suntime-JS

A sandboxed JavaScript interpreter

Test262 Language SuiteTest262 Builtins SuiteTest262 Totals

Sandboxed by Design

Evaluated code is fully isolated from the host. It can only access what you explicitly provide, keeping your application safe from runaway or malicious scripts.

Non-Blocking Execution

Time-sharing and time-bound task runners let you run untrusted code alongside your application without deadlocks or freezes.

TC39 Spec Compliance

Verified against the Test262 test suite. Supports modern JavaScript — async/await, generators, modules, and more.

warning
Suntime-JS is a work in progress. Currently, the majority of the ECMAScript language features are implemented, but support is missing for many built-in APIs. Check the status page for details on what is and isn't supported.

Try it out!

Or try it in the interactive playground complete with variable inspection and breakpoints!

function* getPrimes(limit: number) {
const primes: number[] = [];
let candidate = 2;
while (primes.length < limit) {
if (primes.every((p) => candidate % p !== 0)) {
primes.push(candidate);
yield candidate;
}
candidate++;
}
}

let n = 1;
for (const prime of getPrimes(Infinity)) {
console.log(`The ${st(n)} prime is ${prime}`);
n++;
}

function st(x: number) {
const test = Number(String(x).at(-1));
switch (test) {
case 1:
return x + "st";
case 2:
return x + "nd";
case 3:
return x + "rd";
default:
return x + "th";
}
}