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