@todojs/

4.-callback-hell

JavaScript

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.466147657361752","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"InVzZSBzdHJpY3QiOw0KDQpmdW5jdGlvbiBhc3luY1NxcnQodmFsdWUsIGNhbGxiYWNrKSB7DQogICAgY29uc29sZS5sb2coJ1NUQVJUIGV4ZWN1dGlvbiB3aXRoIHZhbHVlID0nLCB2YWx1ZSk7DQogICAgc2V0VGltZW91dChmdW5jdGlvbiAoKSB7DQogICAgICAgIGNhbGxiYWNrKHZhbHVlLCB2YWx1ZSAqIHZhbHVlKTsNCiAgICB9LCAwIHwgTWF0aC5yYW5kb20oKSAqIDEwMCk7DQp9DQoNCmFzeW5jU3FydCgwLCBmdW5jdGlvbiAodmFsdWUsIHJlc3VsdCkgew0KICAgIGNvbnNvbGUubG9nKCdFTkQgZXhlY3V0aW9uIHdpdGggdmFsdWUgPScsIHZhbHVlLCAnYW5kIHJlc3VsdCA9JywgcmVzdWx0KTsNCiAgICBhc3luY1NxcnQoMSwgZnVuY3Rpb24gKHZhbHVlLCByZXN1bHQpIHsNCiAgICAgICAgY29uc29sZS5sb2coJ0VORCBleGVjdXRpb24gd2l0aCB2YWx1ZSA9JywgdmFsdWUsICdhbmQgcmVzdWx0ID0nLCByZXN1bHQpOw0KICAgICAgICBhc3luY1NxcnQoMiwgZnVuY3Rpb24gKHZhbHVlLCByZXN1bHQpIHsNCiAgICAgICAgICAgIGNvbnNvbGUubG9nKCdFTkQgZXhlY3V0aW9uIHdpdGggdmFsdWUgPScsIHZhbHVlLCAnYW5kIHJlc3VsdCA9JywgcmVzdWx0KTsNCiAgICAgICAgICAgIGFzeW5jU3FydCgzLCBmdW5jdGlvbiAodmFsdWUsIHJlc3VsdCkgew0KICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdFTkQgZXhlY3V0aW9uIHdpdGggdmFsdWUgPScsIHZhbHVlLCAnYW5kIHJlc3VsdCA9JywgcmVzdWx0KTsNCiAgICAgICAgICAgICAgICBhc3luY1NxcnQoNCwgZnVuY3Rpb24gKHZhbHVlLCByZXN1bHQpIHsNCiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ0VORCBleGVjdXRpb24gd2l0aCB2YWx1ZSA9JywgdmFsdWUsICdhbmQgcmVzdWx0ID0nLCByZXN1bHQpOw0KICAgICAgICAgICAgICAgICAgICBhc3luY1NxcnQoNSwgZnVuY3Rpb24gKHZhbHVlLCByZXN1bHQpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdFTkQgZXhlY3V0aW9uIHdpdGggdmFsdWUgPScsIHZhbHVlLCAnYW5kIHJlc3VsdCA9JywgcmVzdWx0KTsNCiAgICAgICAgICAgICAgICAgICAgICAgIGFzeW5jU3FydCg2LCBmdW5jdGlvbiAodmFsdWUsIHJlc3VsdCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdFTkQgZXhlY3V0aW9uIHdpdGggdmFsdWUgPScsIHZhbHVlLCAnYW5kIHJlc3VsdCA9JywgcmVzdWx0KTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhc3luY1NxcnQoNywgZnVuY3Rpb24gKHZhbHVlLCByZXN1bHQpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ0VORCBleGVjdXRpb24gd2l0aCB2YWx1ZSA9JywgdmFsdWUsICdhbmQgcmVzdWx0ID0nLCByZXN1bHQpOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhc3luY1NxcnQoOCwgZnVuY3Rpb24gKHZhbHVlLCByZXN1bHQpIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdFTkQgZXhlY3V0aW9uIHdpdGggdmFsdWUgPScsIHZhbHVlLCAnYW5kIHJlc3VsdCA9JywgcmVzdWx0KTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFzeW5jU3FydCg5LCBmdW5jdGlvbiAodmFsdWUsIHJlc3VsdCkgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCdFTkQgZXhlY3V0aW9uIHdpdGggdmFsdWUgPScsIHZhbHVlLCAnYW5kIHJlc3VsdCA9JywgcmVzdWx0KTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZygnQ09NUExFVEVEJyk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7DQogICAgICAgICAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICAgICAgfSk7DQogICAgICAgICAgICAgICAgfSk7DQogICAgICAgICAgICB9KTsNCiAgICAgICAgfSk7DQogICAgfSk7DQp9KTsg"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"use strict";

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

asyncSqrt(0, function (value, result) {
    console.log('END execution with value =', value, 'and result =', result);
    asyncSqrt(1, function (value, result) {
        console.log('END execution with value =', value, 'and result =', result);
        asyncSqrt(2, function (value, result) {
            console.log('END execution with value =', value, 'and result =', result);
            asyncSqrt(3, function (value, result) {
                console.log('END execution with value =', value, 'and result =', result);
                asyncSqrt(4, function (value, result) {
                    console.log('END execution with value =', value, 'and result =', result);
                    asyncSqrt(5, function (value, result) {
                        console.log('END execution with value =', value, 'and result =', result);
                        asyncSqrt(6, function (value, result) {
                            console.log('END execution with value =', value, 'and result =', result);
                            asyncSqrt(7, function (value, result) {
                                console.log('END execution with value =', value, 'and result =', result);
                                asyncSqrt(8, function (value, result) {
                                    console.log('END execution with value =', value, 'and result =', result);
                                    asyncSqrt(9, function (value, result) {
                                        console.log('END execution with value =', value, 'and result =', result);
                                        console.log('COMPLETED');
                                    });
                                });
                            });
                        });
                    });
                });
            });
        });
    });
}); 
Native Browser JavaScript