MenuEveryday / Run and Run as you type

Docs / Everyday

Run and Run as you type

Press Run when you want, or let JSpark run your Snippet a moment after you stop typing.

On this page

A Run is one execution of your Snippet, from start to finish. It runs as real code: in Node for a Node Snippet, in a real page for a web one.

Run and Stop

  1. Press Run at the top of the rail, or press ⌘↵ or Ctrl+Enter.
  2. Read the result in the console, and in the footer under the code.

You can also choose Run → Run in the menu bar. The Run button is on the rail when Run as you type is off, and when your Snippet reaches outside JSpark.

Run as you type is off: the rail shows Run, and the footer says ⌘↵ to run.

To stop a Run that is still going, press Stop or ⌘. or Ctrl+.. Stop takes the place of Run on the rail, in red, once a Run has lasted half a second. The console keeps what the Run printed before it stopped.

Run as you type

Run as you type is on when you first open JSpark. A moment after you stop typing, JSpark runs your Snippet again. The bolt on the rail is lit, and the footer says Runs as you type.

While a line is typed, the console still shows the last Run. A moment after the typing stops, the new answer arrives.

To turn it off or on, do one of these:

  • Click the bolt on the rail. Off, the bolt is crossed out and Run comes back.
  • Choose Run → Run as You Type.
  • Open Settings → Running → Run as you type.

When you turn it on, JSpark runs the Snippet straight away. To change how long it waits after the last key, set Settings → Running → Auto-run delay: from 150 ms to 1000 ms, 600 ms at first.

Two things pause Run as you type for a Snippet:

  • The Snippet reaches outside JSpark: your files, the network or other programs. The rail shows a warning shield in place of the bolt. Press Run to run it. See My code did not run as I typed.
  • The Timeline is open. The code can't be edited there, and ⌘↵ or Ctrl+Enter records it again.

Code with a mistake still runs as you type. The Run fails, and the console says what is wrong.

Stale output

When you change the code after a Run, JSpark keeps the old output on screen and marks it, so you always know which code it came from:

  • The footer adds code changed since, in the warning colour.
  • When Run is on the rail, it wears a small dot.
  • Peek values beside the code are dimmed.
The code now says Hi, but the console still shows Hello 42, from the last Run. The footer says code changed since.

The next Run replaces the output. Output belongs to its tab. Only a Node Run still going in another tab is affected: it stops.

How a Run ended

The footer starts with how the last Run ended:

The footer saysWhat happened
ReadyThe Snippet has not run yet.
Running…A Run is in progress.
Done in 4msThe Run finished, in that time.
Threw in 3msThe code threw an error. The console shows it.
Didn’t runThe code could not start, for example because of a syntax error. The console says why.
StoppedYou pressed Stop.
Stopped: busy for 5sThe time limit stopped it. See Time and memory limits.
Stopped: used more than 1 GBThe memory limit stopped it.

After it comes when the next Run happens: Runs as you type, ⌘↵ to run, or Runs on demand for a Snippet that reaches outside JSpark.

Good to know

  • JSpark runs one Node Run at a time. Running a Node Snippet in another tab stops a Node Run that is still going.
  • With Run as you type on, a Snippet that has never run runs by itself a moment after it opens, so a Starter’s demo shows its result.
  • A Node Run has your own access to your files, the network and your programs, as any Node program has. See Outside Access.

The pictures show JSpark on a Mac. On Windows, the window looks a little different and uses Ctrl for ⌘, but everything works the same way.

Esc

Type to search every docs page.