Skip to content

@francescoagati /continuation.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
complex continuation with livescript and continuation.js
/* Generated by Continuation.js v0.0.5 */
(function () {
var identity, sum, transform_array, ranges, i$, len$, range;
identity = function (el, callback) {
var delayed;
delayed = function () {
return callback(el);
};
return setTimeout(delayed, 100);
};
sum = function (el, number, callback) {
var delayed;
delayed = function () {
return callback(el + number);
};
return setTimeout(delayed, 100);
};
transform_array = function (list, callback) {
var new_list, i$, len$, n;
new_list = [];
i$ = 0, len$ = list.length;
function loop_0(loop_0_cont) {
if (i$ < len$) {
n = list[i$];
identity(n, function () {
n = arguments[0];
sum(n, 10, function () {
n = arguments[0];
identity(n, function () {
n = arguments[0];
sum(n, 10, function () {
n = arguments[0];
n = n + 100;
(function (cont) {
if (n % 3 === 0) {
identity(n, function () {
n = arguments[0];
sum(n, 10, function () {
n = arguments[0];
identity(n, function () {
n = arguments[0];
sum(n, 10, function () {
n = arguments[0];
identity(n, function () {
n = arguments[0];
sum(n, 10, function () {
n = arguments[0];
if (n > 15) {
new_list.push(n);
}
cont();
});
});
});
});
});
});
} else {
cont();
}
}(function (err) {
if (err !== undefined)
return cont(err);
++i$;
loop_0(loop_0_cont);
}));
});
});
});
});
} else {
loop_0_cont();
}
}
loop_0(function () {
return callback(new_list);
});
};
ranges = [
[
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
],
[
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
],
[
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30
]
];
i$ = 0, len$ = ranges.length;
function loop_1(loop_1_cont) {
if (i$ < len$) {
range = ranges[i$];
transform_array(range, function () {
range = arguments[0];
console.log(range);
++i$;
loop_1(loop_1_cont);
});
} else {
loop_1_cont();
}
}
loop_1(function () {
});
}.call(this));
identity = (el,callback) ->
delayed = -> callback(el)
setTimeout delayed,100
sum = (el,number,callback) ->
delayed = -> callback(el+number)
setTimeout delayed,100
transform_array= (list,callback) ->
new_list=[]
for n in list
identity(n,cont(n))
sum(n,10,cont(n))
identity(n,cont(n))
sum(n,10,cont(n))
n=n+100
if n % 3== 0
identity(n,cont(n))
sum(n,10,cont(n))
identity(n,cont(n))
sum(n,10,cont(n))
identity(n,cont(n))
sum(n,10,cont(n))
# cont(x) is the continuation that put the value of cb function inside x
if n > 15
new_list.push(n)
callback(new_list)
ranges=[[1 to 10],[10 to 20],[20 to 30]]
for range in ranges
transform_array(range,cont(range))
console.log range
function d(a) {
e < h ? (i = j[e], l(i, function(c) {
i = c;
console.log(i);
++e;
d(a)
})) : a()
}
var m, n, l, j, e, h, i;
m = function(a, c) {
setTimeout(function() {
return c(a)
}, 100)
};
n = function(a, c, f) {
setTimeout(function() {
return f(a + c)
}, 100)
};
l = function(a, c) {
function f(c) {
g < p ? (b = a[g], m(b, function(a) {
b = a;
n(b, 10, function(a) {
b = a;
m(b, function(a) {
b = a;
n(b, 10, function(a) {
b = a;
b += 100;
0 === b % 3 ? m(b, function(a) {
b = a;
n(b, 10, function(a) {
b = a;
m(b, function(a) {
b = a;
n(b, 10, function(a) {
b = a;
m(b, function(a) {
b = a;
n(b, 10, function(a) {
b = a;
15 < b && k.push(b);
++g;
f(c)
})
})
})
})
})
}) : (++g, f(c))
})
})
})
})) : c()
}
var k, g, p, b;
k = [];
g = 0;
p = a.length;
f(function() {
return c(k)
})
};
j = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]];
e = 0;
h = j.length;
d(function() {
});
[ 153, 156, 159 ]
[ 162, 165, 168 ]
[ 171, 174, 177, 180 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.