Multithreaded web animations and task chaining. Cue JavaScript methods with greater performance and portability using Web Workers and JSON.
Find a file
Victor Westerlund ef09a568e0
Initial README
Added the initial documentation, more will be added later (perhaps in a wiki)
2021-10-07 13:58:38 +02:00
worker 0.2.1 2021-10-07 12:47:20 +02:00
.gitignore dev21w40a 2021-10-04 17:12:02 +02:00
LICENSE Initial commit 2021-10-04 13:26:38 +02:00
Monkeydo.mjs 0.2.1 2021-10-07 12:47:20 +02:00
README.md Initial README 2021-10-07 13:58:38 +02:00

Threaded task chaining for JavaScript


Monkeydo uses the portable data format JSON to read tasks, making it easy to read by primates and machines alike.

{
  "tasks": [
    [0,"myJavaSriptMethod","someArgument","anotherArgument"]
  ]
}
Array key Description
0 Delay
Wait this many milliseconds before running this task
1 Method
Name of the JavaScript method to call
2+n Arguments
Some amount of arguments to pass to the method

Use Monkeydo

Monkeydo comes as an importable ECMAScript 6 module. In this guide we'll import this directly from a ./modules/ folder, but any web-accesible location will work.

  1. Import Monkeydo from your repo clone or download
    import { default } from "./modules/Monkeydo/Monkeydo.mjs";
    
  2. Define your JS methods
    const methods = {
      myJavaScriptMethod: (foo,bar) => {
        console.log(foo,bar);
      }
    }
    
  3. Define your tasks in a JSON file (or directly in JavaScript)
    {
      "tasks": [
        [0,"myJavaSriptMethod","I see skies of","blue"],
        [300,"myJavaSriptMethod","red","roses too"],
        [160,"myJavaSriptMethod","I see them","bloom"],
        [1200,"myJavaSriptMethod","for","me and you"]
      ]
    }
    
  4. Initialize and run Monkeydo with your methods and manifest
    const monkey = new Monkeydo(methods,manifest);
    monkey.do();
    

The example above would be the same as running:

console.log("I see skies","of blue"); // Right away
console.log("red","roses too"); // 300 milliseconds after the first
console.log("I see them","bloom"); // 160 milliseconds after that one
console.log("for","me and you"); // and lastly, 1200 after that