diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-07-04 00:17:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-04 00:17:52 +0200 |
commit | 5addba2abc2e384e751e8884b4ac3219688c2473 (patch) | |
tree | a5249a82092909f32a852a910e5e144ddeffa497 /runtime/js/40_signals.js | |
parent | ffa75be48044255ed49a822a7a61a2a130123a4a (diff) |
refactor: use primordials in runtime/, part2 (#11248)
Diffstat (limited to 'runtime/js/40_signals.js')
-rw-r--r-- | runtime/js/40_signals.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/runtime/js/40_signals.js b/runtime/js/40_signals.js index bf6be1263..67c1da313 100644 --- a/runtime/js/40_signals.js +++ b/runtime/js/40_signals.js @@ -5,6 +5,14 @@ const core = window.Deno.core; const { build } = window.__bootstrap.build; const { errors } = window.__bootstrap.errors; + const { + Error, + ObjectAssign, + Promise, + PromisePrototypeThen, + PromiseResolve, + SymbolAsyncIterator, + } = window.__bootstrap.primordials; function bindSignal(signo) { return core.opSync("op_signal_bind", signo); @@ -154,9 +162,9 @@ function setSignals() { if (build.os === "darwin") { - Object.assign(Signal, MacOSSignal); + ObjectAssign(Signal, MacOSSignal); } else { - Object.assign(Signal, LinuxSignal); + ObjectAssign(Signal, LinuxSignal); } } @@ -205,7 +213,7 @@ class SignalStream { #disposed = false; - #pollingPromise = Promise.resolve(false); + #pollingPromise = PromiseResolve(false); #rid = 0; constructor(signo) { @@ -236,7 +244,7 @@ f, g, ) { - return this.#pollingPromise.then((done) => { + const p = PromisePrototypeThen(this.#pollingPromise, (done) => { if (done) { // If pollingPromise returns true, then // this signal stream is finished and the promise API @@ -244,14 +252,15 @@ return new Promise(() => {}); } return; - }).then(f, g); + }); + return PromisePrototypeThen(p, f, g); } async next() { return { done: await this.#pollingPromise, value: undefined }; } - [Symbol.asyncIterator]() { + [SymbolAsyncIterator]() { return this; } |