const fs = require('fs');
const [A, B, C] = JSON.parse(fs.readFileSync('input'));
function getA() {
return A;
}
function getB(callback) {
setTimeout(() => {
callback(B);
}, 10);
}
function getC() {
return Promise.resolve().then(() => C);
}
function getABC() {
...
}
getABC().then((arr) => console.log(arr));
const fs = require('fs');
const [A, B, C] = JSON.parse(fs.readFileSync('input'));
const getA = () => A;
const getB = callback => setTimeout(() => callback(B), 10);
const getC = () => Promise.resolve().then(() => C);
const getABC = () => new Promise(resolve => getB(b => resolve(b))).then(b => getC().then(c => [getA(), b, c]));
getABC().then(value => console.log(value));
function getA() {
return 'A';
}
function getB() {
return new Promise(resolve => {
setTimeout(() => {
return resolve('B');
}, 1000);
})
}
function getC() {
return Promise.resolve('C');
}
function getABC() {
return Promise.all([
getA(),
// это типа callback с результатом промиса
getB().then(result => 'Hello from ' + result),
getC()
])
}
console.log( await getABC() )
const A = _ => 'A';
const B = _ => 'B';
const C = _ => 'C';
function getB(callback) {
return new Promise(resolve => {
setTimeout(() => {
resolve(callback);
}, 1000);
})
}
Promise.all([getB(A), getB(B), getB(C)]).then(values => {
const res = values.map(item => item());
console.log(res)
});