Fix semicolons in 1.11.6 (Promisification)

This commit is contained in:
Vse Mozhe Buty 2020-10-31 18:10:32 +02:00 committed by GitHub
parent f2078b1d80
commit d5a88b6b2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,11 +27,11 @@ Let's promisify it. The new `loadScriptPromise(src)` function achieves the same
let loadScriptPromise = function(src) { let loadScriptPromise = function(src) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
loadScript(src, (err, script) => { loadScript(src, (err, script) => {
if (err) reject(err) if (err) reject(err);
else resolve(script); else resolve(script);
}); });
}) });
} };
// usage: // usage:
// loadScriptPromise('path/script.js').then(...) // loadScriptPromise('path/script.js').then(...)
@ -62,7 +62,7 @@ function promisify(f) {
f.call(this, ...args); // call the original function f.call(this, ...args); // call the original function
}); });
}; };
}; }
// usage: // usage:
let loadScriptPromise = promisify(loadScript); let loadScriptPromise = promisify(loadScript);
@ -94,11 +94,11 @@ function promisify(f, manyArgs = false) {
f.call(this, ...args); f.call(this, ...args);
}); });
}; };
}; }
// usage: // usage:
f = promisify(f, true); f = promisify(f, true);
f(...).then(arrayOfResults => ..., err => ...) f(...).then(arrayOfResults => ..., err => ...);
``` ```
For more exotic callback formats, like those without `err` at all: `callback(result)`, we can promisify such functions manually without using the helper. For more exotic callback formats, like those without `err` at all: `callback(result)`, we can promisify such functions manually without using the helper.