UNPKG
p
Version:
latest (0.2.0)
0.2.0
0.1.1
0.1.0
0.0.4
0.0.3
0.0.2
0.0.1
pattern matching in javascript for asyncronous iteration
github.com/dscape/p
dscape/p
p
/
samples
/
map_async.test.js
8 lines
(6 loc)
•
236 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
/* [ 2, 4, 6 ] */
var
map_async =
require
(
'./hof'
).
map_async
;
function
duplicate
(
x, cb
) {
setTimeout
(
function
(
) {
cb
(x*
2
); },
Math
.
ceil
(
Math
.
random
() *
100
)); }
map_async
(duplicate, [
1
,
2
,
3
], [],
function
(
ac
) {
console
.
error
(ac); });