mirror of
https://codeberg.org/vlw/monkeydo.git
synced 2025-09-13 15:53:40 +02:00
Update README.md
This commit is contained in:
parent
539690cbdd
commit
9e362617e9
1 changed files with 13 additions and 15 deletions
28
README.md
28
README.md
|
@ -38,12 +38,12 @@
|
||||||
<h1 align="center">Use Monkeydo</h1>
|
<h1 align="center">Use Monkeydo</h1>
|
||||||
<p>Monkeydo comes as an importable ECMAScript 6 module. In this guide we'll import this directly from a <i>./modules/</i> folder, but any web-accesible location will work.</p>
|
<p>Monkeydo comes as an importable ECMAScript 6 module. In this guide we'll import this directly from a <i>./modules/</i> folder, but any web-accesible location will work.</p>
|
||||||
<ol>
|
<ol>
|
||||||
<li>Import <code>Monkeydo</code> from your repo clone or download
|
<li><strong>Import <code>Monkeydo</code> as an ES6 module</strong>
|
||||||
<pre lang="js">
|
<pre lang="js">
|
||||||
import { default } from "./modules/Monkeydo/Monkeydo.mjs";
|
import { default as Monkeydo } from "./modules/Monkeydo/Monkeydo.mjs";
|
||||||
</pre>
|
</pre>
|
||||||
</li>
|
</li>
|
||||||
<li>Define your JS methods
|
<li><strong>Define your JS methods in an object</strong>
|
||||||
<pre lang="js">
|
<pre lang="js">
|
||||||
const methods = {
|
const methods = {
|
||||||
myJavaScriptMethod: (foo,bar) => {
|
myJavaScriptMethod: (foo,bar) => {
|
||||||
|
@ -52,29 +52,27 @@ const methods = {
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</li>
|
</li>
|
||||||
<li>Define your tasks in a JSON file (or directly in JavaScript)
|
<li><strong>Define your tasks in a JSON manifest (file or JSON-compatible JavaScript)</strong>
|
||||||
<pre lang="json">
|
<pre lang="json">
|
||||||
{
|
{
|
||||||
"tasks": [
|
"tasks": [
|
||||||
[0,"myJavaSriptMethod","I see trees of","green"],
|
[0,"myJavaSriptMethod","Just like a","monkey"],
|
||||||
[300,"myJavaSriptMethod","red","roses too"],
|
[1200,"myJavaSriptMethod","I've been","dancing"],
|
||||||
[160,"myJavaSriptMethod","I see them","bloom"],
|
[160,"myJavaSriptMethod","my whole","life"]
|
||||||
[1200,"myJavaSriptMethod","for","me and you"]
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</li>
|
</li>
|
||||||
<li>Initialize and run <code>Monkeydo</code> with your methods and manifest
|
<li><strong>Initialize and run <code>Monkeydo</code> with your methods and manifest</strong>
|
||||||
<pre lang="js">
|
<pre lang="js">
|
||||||
const monkey = new Monkeydo(methods,manifest);
|
const monkey = new Monkeydo(methods);
|
||||||
monkey.do();
|
monkey.play(manifest);
|
||||||
</pre>
|
</pre>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
<p>The example above would be the same as running:</p>
|
<p>The example above would be the same as running:</p>
|
||||||
<pre lang="js">
|
<pre lang="js">
|
||||||
console.log("I see trees of","green"); // Right away
|
console.log("Just like a","monkey"); // Right away
|
||||||
console.log("red","roses too"); // 300 milliseconds after the first
|
console.log("I've been","dancing"); // 1.2 seconds after the first
|
||||||
console.log("I see them","bloom"); // 160 milliseconds after that one
|
console.log("my whole","life"); // and then 160 milliseconds after the second
|
||||||
console.log("for","me and you"); // and lastly, 1200 after that
|
|
||||||
</pre>
|
</pre>
|
||||||
|
|
Loading…
Add table
Reference in a new issue