summaryrefslogtreecommitdiff
path: root/ext/net/01_net.js
diff options
context:
space:
mode:
authorKenta Moriuchi <moriken@kimamass.com>2023-05-01 22:30:02 +0900
committerGitHub <noreply@github.com>2023-05-01 15:30:02 +0200
commit6728ad4203d731e555dabf89ec6157f113454ce6 (patch)
tree956dc2d403b5a6ef107c35cab1ccc259ad4d86a1 /ext/net/01_net.js
parent94a148cdb6f7660518c75a3c20109bf64848f0f1 (diff)
fix(core): Use primordials for methods (#18839)
I would like to get this change into Deno before merging https://github.com/denoland/deno_lint/pull/1152
Diffstat (limited to 'ext/net/01_net.js')
-rw-r--r--ext/net/01_net.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/ext/net/01_net.js b/ext/net/01_net.js
index 81e13f094..e8ce3a300 100644
--- a/ext/net/01_net.js
+++ b/ext/net/01_net.js
@@ -11,13 +11,16 @@ import {
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
const primordials = globalThis.__bootstrap.primordials;
const {
+ ArrayPrototypeFilter,
+ ArrayPrototypeForEach,
+ ArrayPrototypePush,
Error,
ObjectPrototypeIsPrototypeOf,
PromiseResolve,
SymbolAsyncIterator,
SymbolFor,
- TypedArrayPrototypeSubarray,
TypeError,
+ TypedArrayPrototypeSubarray,
Uint8Array,
} = primordials;
@@ -97,15 +100,16 @@ class Conn {
const promise = core.read(this.rid, buffer);
const promiseId = promise[promiseIdSymbol];
if (this.#unref) core.unrefOp(promiseId);
- this.#pendingReadPromiseIds.push(promiseId);
+ ArrayPrototypePush(this.#pendingReadPromiseIds, promiseId);
let nread;
try {
nread = await promise;
} catch (e) {
throw e;
} finally {
- this.#pendingReadPromiseIds = this.#pendingReadPromiseIds.filter((id) =>
- id !== promiseId
+ this.#pendingReadPromiseIds = ArrayPrototypeFilter(
+ this.#pendingReadPromiseIds,
+ (id) => id !== promiseId,
);
}
return nread === 0 ? null : nread;
@@ -141,7 +145,7 @@ class Conn {
if (this.#readable) {
readableStreamForRidUnrefableRef(this.#readable);
}
- this.#pendingReadPromiseIds.forEach((id) => core.refOp(id));
+ ArrayPrototypeForEach(this.#pendingReadPromiseIds, (id) => core.refOp(id));
}
unref() {
@@ -149,7 +153,10 @@ class Conn {
if (this.#readable) {
readableStreamForRidUnrefableUnref(this.#readable);
}
- this.#pendingReadPromiseIds.forEach((id) => core.unrefOp(id));
+ ArrayPrototypeForEach(
+ this.#pendingReadPromiseIds,
+ (id) => core.unrefOp(id),
+ );
}
}