Skip to content

Commit 17f363d

Browse files
author
Josh Goldberg
committed
Readme update for TimeHandlr
1 parent 1acfa54 commit 17f363d

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

src/TimeHandlr/README.md

+23-27
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
EventHandlr.js
1+
TimeHandlr.js
22
==============
33

4-
A timed events library derived from Full Screen Mario
5-
This has two functions:
4+
A timed events library derived from Full Screen Mario. It keeps a listing of functions to execute at certain timeouts and intervals, separate from Javascript's native methods.
5+
This has two primary applications:
66
<ol>
77
<li>Provide a flexible alternative to setTimeout and setInterval that respects pauses and resumes in time (such as from game pauses)</li>
88
<li>Provide functions to automatically 'cycle' between certain classes on an object</li>
@@ -26,7 +26,7 @@ Essential Functions
2626
window.MyEventHandler = new EventHandlr();</code><br /><code>
2727
MyEventHandler.addEvent(function() { console.log("It's starting!"); });</code><br /><code>
2828
MyEventHandler.addEvent(function() { console.log("It has ended.."); }, 49);</code><br /><code>
29-
MyEventHandler.addEvent(function() { console.log("Can you see why this won't be reached?"); }, 96);</code><br /><code>
29+
MyEventHandler.addEvent(function() { console.log("This won't be reached!"); }, 96);</code><br /><code>
3030
MyEventHandler.addEventInterval(function() { console.log("Running..."); }, 7, 6);</code><br /><code>
3131
for(var i = 0; i < 70; ++i)</code><br /><code>
3232
MyEventHandler.handleEvents();
@@ -52,13 +52,11 @@ Essential Functions
5252

5353
<tr>
5454
<th>Command</th>
55-
<th>Usage</th>
5655
<th>Result</th>
5756
</tr>
5857

5958
<tr>
60-
<td><h3>new EventHandlr</h3></td>
61-
<td>
59+
<td><h3>new EventHandlr</h3>
6260
<code><strong>new EventHandlr</strong>();</code>
6361
<p>(or)</p>
6462
<code>
@@ -100,8 +98,7 @@ Essential Functions
10098
</tr>
10199

102100
<tr>
103-
<td><h3>handleEvents</h3></td>
104-
<td>
101+
<td><h3>handleEvents</h3>
105102
<code><strong>handleEvents</strong>)</code>
106103
</td>
107104
<td>
@@ -115,9 +112,10 @@ Essential Functions
115112
</tr>
116113

117114
<tr>
118-
<td><h3>addEvent</h3></td>
119-
<td>
120-
<code><strong>addEvent</strong>(function, time_delay=1[, arguments...]);</code>
115+
<td><h3>addEvent</h3>
116+
<code><strong>addEvent</strong>(function,</code><br /><code>
117+
time_delay=1</code><br /><code>
118+
[, arguments...]);</code>
121119
</td>
122120
<td>
123121
<p>Will run the <code>function</code> in <code>time_delay</code> ticks, passing any given arguments. This is equivalent to <code>setTimeout(function)</code>.</p>
@@ -132,9 +130,11 @@ Essential Functions
132130
</tr>
133131

134132
<tr>
135-
<td><h3>addEventInterval</h3></td>
136-
<td>
137-
<code><strong>addEventInterval</strong>(function, time_delay=1, num_repeats[, arguments...]);</code>
133+
<td><h3>addEventInterval</h3>
134+
<code><strong>addEventInterval</strong>(function,</code><br /><code>
135+
time_delay=1,</code><br /><code>
136+
num_repeats</code><br /><code>
137+
[, arguments...]);</code>
138138
</td>
139139
<td>
140140
<p>Will run the <code>function</code> in <code>time_delay</code> ticks a <code>num_repeats</code> number of times, passing any given arguments. <code>num_repeats</code> may be a function to evaluate or a typical number. This is equivalent to <code>setInterval(function)</code>.</p>
@@ -145,8 +145,7 @@ Essential Functions
145145
</tr>
146146

147147
<tr>
148-
<td><h3>clearEvent</h3></td>
149-
<td>
148+
<td><h3>clearEvent</h3>
150149
<code><strong>clearEvent</strong>(event);</code>
151150
</td>
152151
<td>
@@ -159,8 +158,7 @@ Essential Functions
159158
</tr>
160159

161160
<tr>
162-
<td><h3>clearAllEvents</h3></td>
163-
<td>
161+
<td><h3>clearAllEvents</h3>
164162
<code><strong>clearAllEvents</strong>();</code>
165163
</td>
166164
<td>
@@ -190,9 +188,10 @@ Class Cycling
190188
<code>
191189
window.MyEventHandler = new EventHandlr();</code><br /><code>
192190
var me = { className: "myclass", doSpriteCycleStart: true};</code><br /><code>
191+
var log = function log = console.log.bind(console);</code><br /><code>
193192
MyEventHandler.addSpriteCycle(me, ["one", "two", "three"]);</code><br /><code>
194-
MyEventHandler.addEventInterval(function(my_obj) { console.log(my_obj.className); }, 7, Infinity, me);</code><br /><code>
195-
console.log(me.className, "(starting)");</code><br /><code>
193+
MyEventHandler.addEventInterval(log, 7, Infinity, me);</code><br /><code>
194+
log(me.className, "(starting)");</code><br /><code>
196195
for(var i = 0; i < 49; ++i)</code><br /><code>
197196
MyEventHandler.handleEvents();
198197
</code>
@@ -217,13 +216,11 @@ Class Cycling
217216

218217
<tr>
219218
<th>Command</th>
220-
<th>Usage</th>
221219
<th>Output</th>
222220
</tr>
223221

224222
<tr>
225-
<td><h3>addSpriteCycle</h3></td>
226-
<td>
223+
<td><h3>addSpriteCycle</h3>
227224
<code><strong>addSpriteCycle</strong>(me, classnames[, cyclename[, cycletime]])</code>
228225
<td>
229226
<p>Initializes a cycle of <code>.className</code>s for an object. The object will continuously cycle through them until <code>clearAllCycles</code> or <code>clearClassCycle</code> are called.</p>
@@ -235,8 +232,7 @@ Class Cycling
235232
</tr>
236233

237234
<tr>
238-
<td><h3>addSpriteCycleSynched</h3></td>
239-
<td>
235+
<td><h3>addSpriteCycleSynched</h3>
240236
<code><strong>addSpriteCycleSynched</strong>(me, classnames[, cyclename[, cycletime]])</code>
241237
</td>
242238
<td>
@@ -246,4 +242,4 @@ Class Cycling
246242
MyEventHandler.addSpriteCycleSynched(me, ["one", "two", "three"]);
247243
</code>
248244
</td>
249-
</tr>
245+
</tr>

0 commit comments

Comments
 (0)