summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/_util
diff options
context:
space:
mode:
authorKenta Moriuchi <moriken@kimamass.com>2024-01-11 07:37:25 +0900
committerGitHub <noreply@github.com>2024-01-10 15:37:25 -0700
commit515a34b4de222e35c7ade1b92614d746e73d4c2e (patch)
tree8284201fc826a33f12597959a8a8be14e0f524bd /ext/node/polyfills/_util
parentd4893eb51a01c5a692d8ca74a3b8ff95c5fd1d9f (diff)
refactor: use `core.ensureFastOps()` (#21888)
Diffstat (limited to 'ext/node/polyfills/_util')
-rw-r--r--ext/node/polyfills/_util/_util_callbackify.ts3
-rw-r--r--ext/node/polyfills/_util/async.ts3
-rw-r--r--ext/node/polyfills/_util/os.ts6
-rw-r--r--ext/node/polyfills/_util/std_asserts.ts15
-rw-r--r--ext/node/polyfills/_util/std_testing_diff.ts27
5 files changed, 30 insertions, 24 deletions
diff --git a/ext/node/polyfills/_util/_util_callbackify.ts b/ext/node/polyfills/_util/_util_callbackify.ts
index 582a16077..0ea4d0881 100644
--- a/ext/node/polyfills/_util/_util_callbackify.ts
+++ b/ext/node/polyfills/_util/_util_callbackify.ts
@@ -24,7 +24,6 @@
// These are simplified versions of the "real" errors in Node.
import { primordials } from "ext:core/mod.js";
-import { nextTick } from "ext:deno_node/_next_tick.ts";
const {
ArrayPrototypePop,
Error,
@@ -36,6 +35,8 @@ const {
TypeError,
} = primordials;
+import { nextTick } from "ext:deno_node/_next_tick.ts";
+
class NodeFalsyValueRejectionError extends Error {
public reason: unknown;
public code = "ERR_FALSY_VALUE_REJECTION";
diff --git a/ext/node/polyfills/_util/async.ts b/ext/node/polyfills/_util/async.ts
index 6d65c402a..cc116412c 100644
--- a/ext/node/polyfills/_util/async.ts
+++ b/ext/node/polyfills/_util/async.ts
@@ -3,12 +3,13 @@
// (with some modifications)
import { primordials } from "ext:core/mod.js";
-import { clearTimeout, setTimeout } from "ext:deno_web/02_timers.js";
const {
Promise,
PromiseReject,
} = primordials;
+import { clearTimeout, setTimeout } from "ext:deno_web/02_timers.js";
+
/** Resolve a Promise after a given amount of milliseconds. */
export function delay(
ms: number,
diff --git a/ext/node/polyfills/_util/os.ts b/ext/node/polyfills/_util/os.ts
index 239419d91..8a3d9edf4 100644
--- a/ext/node/polyfills/_util/os.ts
+++ b/ext/node/polyfills/_util/os.ts
@@ -1,7 +1,9 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core } from "ext:core/mod.js";
-const ops = core.ops;
+const {
+ op_node_build_os,
+} = core.ensureFastOps(true);
export type OSType =
| "windows"
@@ -11,7 +13,7 @@ export type OSType =
| "freebsd"
| "openbsd";
-export const osType: OSType = ops.op_node_build_os();
+export const osType: OSType = op_node_build_os();
export const isWindows = osType === "windows";
export const isLinux = osType === "linux" || osType === "android";
diff --git a/ext/node/polyfills/_util/std_asserts.ts b/ext/node/polyfills/_util/std_asserts.ts
index f25904251..78b749f54 100644
--- a/ext/node/polyfills/_util/std_asserts.ts
+++ b/ext/node/polyfills/_util/std_asserts.ts
@@ -2,13 +2,6 @@
// vendored from std/assert/mod.ts
import { primordials } from "ext:core/mod.js";
-import { URLPrototype } from "ext:deno_url/00_url.js";
-import { red } from "ext:deno_node/_util/std_fmt_colors.ts";
-import {
- buildMessage,
- diff,
- diffstr,
-} from "ext:deno_node/_util/std_testing_diff.ts";
const {
DatePrototype,
ArrayPrototypeJoin,
@@ -37,6 +30,14 @@ const {
WeakRefPrototypeDeref,
} = primordials;
+import { URLPrototype } from "ext:deno_url/00_url.js";
+import { red } from "ext:deno_node/_util/std_fmt_colors.ts";
+import {
+ buildMessage,
+ diff,
+ diffstr,
+} from "ext:deno_node/_util/std_testing_diff.ts";
+
const FORMAT_PATTERN = new SafeRegExp(/(?=["\\])/g);
/** Converts the input into a string. Objects, Sets and Maps are sorted so as to
diff --git a/ext/node/polyfills/_util/std_testing_diff.ts b/ext/node/polyfills/_util/std_testing_diff.ts
index 878e21f0b..74e396b0c 100644
--- a/ext/node/polyfills/_util/std_testing_diff.ts
+++ b/ext/node/polyfills/_util/std_testing_diff.ts
@@ -2,15 +2,6 @@
// This file was vendored from std/testing/_diff.ts
import { primordials } from "ext:core/mod.js";
-import {
- bgGreen,
- bgRed,
- bold,
- gray,
- green,
- red,
- white,
-} from "ext:deno_node/_util/std_fmt_colors.ts";
const {
ArrayFrom,
ArrayPrototypeFilter,
@@ -23,19 +14,29 @@ const {
ArrayPrototypeReverse,
ArrayPrototypeShift,
ArrayPrototypeSlice,
- ArrayPrototypeSplice,
ArrayPrototypeSome,
+ ArrayPrototypeSplice,
ArrayPrototypeUnshift,
+ MathMin,
+ ObjectFreeze,
SafeArrayIterator,
SafeRegExp,
- StringPrototypeSplit,
StringPrototypeReplace,
+ StringPrototypeSplit,
StringPrototypeTrim,
- MathMin,
- ObjectFreeze,
Uint32Array,
} = primordials;
+import {
+ bgGreen,
+ bgRed,
+ bold,
+ gray,
+ green,
+ red,
+ white,
+} from "ext:deno_node/_util/std_fmt_colors.ts";
+
interface FarthestPoint {
y: number;
id: number;