@todojs/

5.-llamadas-encadenadas

JavaScript

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9394517427468987","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"InVzZSBzdHJpY3QiOw0KDQpmdW5jdGlvbiBhc3luY1NxcnQodmFsdWUsIGNhbGxiYWNrKSB7DQogICAgY29uc29sZS5sb2coJ1NUQVJUIGV4ZWN1dGlvbiB3aXRoIHZhbHVlID0nLCB2YWx1ZSk7DQogICAgc2V0VGltZW91dChmdW5jdGlvbigpIHsNCiAgICAgICAgY2FsbGJhY2sodmFsdWUsIHZhbHVlICogdmFsdWUpOw0KICAgIH0sIDAgfCBNYXRoLnJhbmRvbSgpICogMTAwKTsNCn0NCg0KdmFyIG1heCA9IDEwOw0KdmFyIGNudCA9IDA7DQphc3luY1NxcnQoY250LCBmdW5jdGlvbiBjYWxsYmFjayh2YWx1ZSwgcmVzdWx0KSB7DQogICAgY29uc29sZS5sb2coJ0VORCBleGVjdXRpb24gd2l0aCB2YWx1ZSA9JywgdmFsdWUsICdhbmQgcmVzdWx0ID0nLCByZXN1bHQpOw0KICAgIGlmICgrK2NudCA9PT0gbWF4KSB7DQogICAgICAgIGNvbnNvbGUubG9nKCdDT01QTEVURUQnKTsNCiAgICB9IGVsc2Ugew0KICAgICAgICBhc3luY1NxcnQoY250LCBjYWxsYmFjayk7DQogICAgfQ0KfSk7"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"use strict";

function asyncSqrt(value, callback) {
    console.log('START execution with value =', value);
    setTimeout(function() {
        callback(value, value * value);
    }, 0 | Math.random() * 100);
}

var max = 10;
var cnt = 0;
asyncSqrt(cnt, function callback(value, result) {
    console.log('END execution with value =', value, 'and result =', result);
    if (++cnt === max) {
        console.log('COMPLETED');
    } else {
        asyncSqrt(cnt, callback);
    }
});
Native Browser JavaScript