Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function repeat(operation, num) {
- if (num <= 0) {
- return;
- }
- operation();
- return function() {
- return repeat(operation, --num);
- };
- }
- function trampoline(fn) {
- var args = Array.prototype.slice.call(arguments, 1);
- var result = fn.apply(null, args);
- while (!!result) {
- result = result();
- }
- }
- module.exports = function(operation, num) {
- return trampoline(repeat, operation, num);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement