Skip to content

duncanbeevers/bobble

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Bobble

Simulated asynch environment for JavaScript

Usage

Create a new bobble with some asynchronous behavior.

var bobble = new Bobble("
  var a = false;
  setTimeout(function() { a = true; }, 100);
  advanceToTime(100);
  console.log(a);
");

Within the bobble time can be manually advanced using advanceToTime to execute scheduled events. You can advanceToTime with the same value to trigger instantaneous events like those scheduled by postMessage

The time covered advanceToTime is treated as though the JavaScript thread was busy during the interval. This means that intervals that would have fired multiple times within that interval will fire only once.

Ask the bobble to execute its payload.

bobble.run();

Simulated

Inside the bobble, time-dependent asynchronous JavaScript is executed synchronously, and the passage of time is metered out manually. The system simulates:

  • setTimeout
  • setInterval
  • clearTimeout
  • clearInterval
  • postMessage
  • window.addEventListener('message', receiver)
  • Date

Releases

No releases published

Packages

No packages published