flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
30
VISUALIZACION/node_modules/parcel-bundler/lib/utils/syncPromise.js
generated
vendored
Executable file
30
VISUALIZACION/node_modules/parcel-bundler/lib/utils/syncPromise.js
generated
vendored
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
'use strict';
|
||||
|
||||
const deasync = require('deasync');
|
||||
|
||||
/**
|
||||
* Synchronously waits for a promise to return by
|
||||
* yielding to the node event loop as needed.
|
||||
*/
|
||||
function syncPromise(promise) {
|
||||
let isDone = false;
|
||||
let res, err;
|
||||
|
||||
promise.then(value => {
|
||||
res = value;
|
||||
isDone = true;
|
||||
}, error => {
|
||||
err = error;
|
||||
isDone = true;
|
||||
});
|
||||
|
||||
deasync.loopWhile(() => !isDone);
|
||||
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
module.exports = syncPromise;
|
||||
Loading…
Add table
Add a link
Reference in a new issue