@todojs/

1.-asyncSqrt

JavaScript

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.8249126141368301","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"InVzZSBzdHJpY3QiOw0KDQpmdW5jdGlvbiBhc3luY1NxcnQodmFsdWUsIGNhbGxiYWNrKSB7DQogICAgY29uc29sZS5sb2coJ1NUQVJUIGV4ZWN1dGlvbiB3aXRoIHZhbHVlID0nLCB2YWx1ZSk7DQogICAgc2V0VGltZW91dChmdW5jdGlvbigpIHsNCiAgICAgICAgY2FsbGJhY2sodmFsdWUsIHZhbHVlICogdmFsdWUpOw0KICAgIH0sIDAgfCBNYXRoLnJhbmRvbSgpICogMTAwKTsNCn0NCg0KYXN5bmNTcXJ0KDIsIGZ1bmN0aW9uKHZhbHVlLCByZXN1bHQpIHsNCiAgICBjb25zb2xlLmxvZygnRU5EIGV4ZWN1dGlvbiB3aXRoIHZhbHVlID0nLCB2YWx1ZSwgJ2FuZCByZXN1bHQgPScsIHJlc3VsdCk7DQp9KTsNCmNvbnNvbGUubG9nKCdDT01QTEVURUQgPycpOw=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
"use strict";

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

asyncSqrt(2, function(value, result) {
    console.log('END execution with value =', value, 'and result =', result);
});
console.log('COMPLETED ?');
Native Browser JavaScript