|
|
|
@ -1,4 +1,3 @@
|
|
|
|
|
import { deferedSpawn } from "async-spawner";
|
|
|
|
|
import Emittery from "emittery";
|
|
|
|
|
import { promisify } from "util";
|
|
|
|
|
|
|
|
|
@ -78,16 +77,16 @@ class AbortablePromise<T> extends Promise<T | null> {
|
|
|
|
|
|
|
|
|
|
// setTimeout(() => a.abort(), 1500);
|
|
|
|
|
|
|
|
|
|
const b = new AbortablePromise(async function* (await_or_abort) {
|
|
|
|
|
const ping = await deferedSpawn("ping", ["8.8.8.8"]);
|
|
|
|
|
while (true) {
|
|
|
|
|
console.log(
|
|
|
|
|
await await_or_abort(ping.waitForNextData(), () => {
|
|
|
|
|
ping.kill();
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
yield;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// const b = new AbortablePromise(async function* (await_or_abort) {
|
|
|
|
|
// const ping = await deferedSpawn("ping", ["8.8.8.8"]);
|
|
|
|
|
// while (true) {
|
|
|
|
|
// console.log(
|
|
|
|
|
// await await_or_abort(ping.waitForNextData(), () => {
|
|
|
|
|
// ping.kill();
|
|
|
|
|
// })
|
|
|
|
|
// );
|
|
|
|
|
// yield;
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
setTimeout(() => b.abort(), 5000);
|
|
|
|
|
// setTimeout(() => b.abort(), 5000);
|
|
|
|
|