mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
Hello airbnb
This commit is contained in:
1 parent
f9468536de
commit
8c195661d7
78 files changed
+2032
-1471
No files matched your search
+12
-13
@@ -1,6 +1,6 @@
|
||||
let q = {};
|
||||
const q = {};
|
||||
module.exports = {
|
||||
async connect() { },
|
||||
async connect() { }, // eslint-disable-line no-empty-function
|
||||
async assert(queue) {
|
||||
q[queue] = q[queue] || [];
|
||||
},
|
||||
@@ -9,20 +9,19 @@ module.exports = {
|
||||
},
|
||||
async get(queue, wait = true) {
|
||||
if (wait) {
|
||||
while (!q[queue].length)
|
||||
await new Promise(resolve => {
|
||||
while (!q[queue].length) {
|
||||
await new Promise((resolve) => { // eslint-disable-line no-await-in-loop
|
||||
setTimeout(resolve, 100);
|
||||
});
|
||||
let data = q[queue][0];
|
||||
}
|
||||
const data = q[queue][0];
|
||||
q[queue].splice(0, 1);
|
||||
return data;
|
||||
} else {
|
||||
if (!q[queue].length) return null;
|
||||
else {
|
||||
let data = q[queue][0];
|
||||
q[queue].splice(0, 1);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!q[queue].length) return null;
|
||||
|
||||
const data = q[queue][0];
|
||||
q[queue].splice(0, 1);
|
||||
return data;
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user