@@ -39,30 +39,31 @@ Or build with pakmanager:
39
39
pakmanager build lateral
40
40
```
41
41
42
- Standalone Usage
42
+ Usage
43
43
---
44
44
45
45
``` javascript
46
46
;(function () {
47
47
' use strict' ;
48
48
49
- var Lateral = require (' lateral' ).Lateral
49
+ var Lateral = window . Lateral || require (' lateral' ).Lateral
50
50
, maxCallsAtOnce = 4 // default
51
51
, lateral
52
52
;
53
53
54
- lateral = Lateral . create ( function (complete , item , i ) {
54
+ function onEach (complete , item , i ) {
55
55
setTimeout (function () {
56
56
console .log (item);
57
57
complete ();
58
58
}, 500 );
59
- }, maxCallsAtOnce);
59
+ }
60
60
61
- lateral .add ([' a' , ' b' , ' c' , ' d' ]).when (function () {
62
- console .log (' did all the things' );
63
- });
61
+ lateral = Lateral .create (onEach, maxCallsAtOnce);
64
62
65
- lateral .add ([' d' , ' e' , ' f' , ' g' ]).when (function () {
63
+ lateral .add ([' a' , ' b' , ' c' , ' d' ]);
64
+ lateral .add ([' d' , ' e' , ' f' , ' g' ]);
65
+
66
+ lateral .then (function () {
66
67
console .log (' did all the things' );
67
68
});
68
69
}());
@@ -75,10 +76,8 @@ Creates a Sequence-ish object for the purpose of synchronizing other Futures.
75
76
76
77
** Core**
77
78
78
- * ` lateral = Lateral.create(handler , n) `
79
+ * ` lateral = Lateral.create(fn , n) `
79
80
* create a Lateral that will execute ` fn ` on each item to do at most ` n ` things at once
80
-
81
81
* ` lateral.add(arr) ` - adds ` arr ` to be handled by ` fn `
82
-
83
- * ` lateral.add(arr).when(callback) `
84
- * Fires ` callback ` when all items in the ` arr ` batch have been handled
82
+ * ` lateral.then(callback) `
83
+ * Fires ` callback ` when all items in the ` arr ` have been handled
0 commit comments