diff options
Diffstat (limited to 'ext/node')
-rw-r--r-- | ext/node/lib.rs | 6 | ||||
-rw-r--r-- | ext/node/polyfills/internal/console/constructor.mjs | 8 | ||||
-rw-r--r-- | ext/node/polyfills/internal_binding/types.ts | 58 | ||||
-rw-r--r-- | ext/node/polyfills/internal_binding/util.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/util.ts | 10 |
5 files changed, 18 insertions, 66 deletions
diff --git a/ext/node/lib.rs b/ext/node/lib.rs index dd3acd17c..42a752791 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -151,11 +151,6 @@ fn op_node_build_os() -> String { } #[op2(fast)] -fn op_is_any_arraybuffer(value: &v8::Value) -> bool { - value.is_array_buffer() || value.is_shared_array_buffer() -} - -#[op2(fast)] fn op_node_is_promise_rejected(value: v8::Local<v8::Value>) -> bool { let Ok(promise) = v8::Local::<v8::Promise>::try_from(value) else { return false; @@ -286,7 +281,6 @@ deno_core::extension!(deno_node, ops::os::op_node_os_username<P>, ops::os::op_geteuid<P>, op_node_build_os, - op_is_any_arraybuffer, op_node_is_promise_rejected, op_npm_process_state, ops::require::op_require_init_paths, diff --git a/ext/node/polyfills/internal/console/constructor.mjs b/ext/node/polyfills/internal/console/constructor.mjs index afa18bb97..e9160cf70 100644 --- a/ext/node/polyfills/internal/console/constructor.mjs +++ b/ext/node/polyfills/internal/console/constructor.mjs @@ -4,6 +4,9 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials +import { core } from "ext:core/mod.js"; +const ops = core.ops; + // Mock trace for now const trace = () => {}; import { @@ -17,7 +20,6 @@ import { validateInteger, validateObject, } from "ext:deno_node/internal/validators.mjs"; -import { previewEntries } from "ext:deno_node/internal_binding/util.ts"; import { Buffer } from "node:buffer"; const { isBuffer } = Buffer; import { @@ -500,7 +502,7 @@ const consoleMethods = { let isKeyValue = false; let i = 0; if (mapIter) { - const res = previewEntries(tabularData, true); + const res = ops.op_preview_entries(tabularData, true); tabularData = res[0]; isKeyValue = res[1]; } @@ -535,7 +537,7 @@ const consoleMethods = { const setIter = isSetIterator(tabularData); if (setIter) { - tabularData = previewEntries(tabularData); + tabularData = ops.op_preview_entries(tabularData, false); } const setlike = setIter || mapIter || isSet(tabularData); diff --git a/ext/node/polyfills/internal_binding/types.ts b/ext/node/polyfills/internal_binding/types.ts index fe697f194..1f0528b2f 100644 --- a/ext/node/polyfills/internal_binding/types.ts +++ b/ext/node/polyfills/internal_binding/types.ts @@ -27,9 +27,6 @@ const { core } = globalThis.__bootstrap; const { ops } = core; -// https://tc39.es/ecma262/#sec-object.prototype.tostring -const _toString = Object.prototype.toString; - // https://tc39.es/ecma262/#sec-bigint.prototype.valueof const _bigIntValueOf = BigInt.prototype.valueOf; @@ -94,11 +91,7 @@ export function isAnyArrayBuffer( } export function isArgumentsObject(value: unknown): value is IArguments { - return ( - isObjectLike(value) && - value[Symbol.toStringTag] === undefined && - _toString.call(value) === "[object Arguments]" - ); + return ops.op_is_arguments_object(value); } export function isArrayBuffer(value: unknown): value is ArrayBuffer { @@ -113,11 +106,7 @@ export function isArrayBuffer(value: unknown): value is ArrayBuffer { export function isAsyncFunction( value: unknown, ): value is (...args: unknown[]) => Promise<unknown> { - return ( - typeof value === "function" && - // @ts-ignore: function is a kind of object - value[Symbol.toStringTag] === "AsyncFunction" - ); + return ops.op_is_async_function(value); } // deno-lint-ignore ban-types @@ -166,18 +155,11 @@ export function isDate(value: unknown): value is Date { export function isGeneratorFunction( value: unknown, ): value is GeneratorFunction { - return ( - typeof value === "function" && - // @ts-ignore: function is a kind of object - value[Symbol.toStringTag] === "GeneratorFunction" - ); + return ops.op_is_generator_function(value); } export function isGeneratorObject(value: unknown): value is Generator { - return ( - isObjectLike(value) && - value[Symbol.toStringTag] === "Generator" - ); + return ops.op_is_generator_object(value); } export function isMap(value: unknown): value is Map<unknown, unknown> { @@ -192,27 +174,17 @@ export function isMap(value: unknown): value is Map<unknown, unknown> { export function isMapIterator( value: unknown, ): value is IterableIterator<[unknown, unknown]> { - return ( - isObjectLike(value) && - value[Symbol.toStringTag] === "Map Iterator" - ); + return ops.op_is_map_iterator(value); } export function isModuleNamespaceObject( value: unknown, ): value is Record<string | number | symbol, unknown> { - return ( - isObjectLike(value) && - value[Symbol.toStringTag] === "Module" - ); + return ops.op_is_module_namespace_object(value); } export function isNativeError(value: unknown): value is Error { - return ( - isObjectLike(value) && - value[Symbol.toStringTag] === undefined && - _toString.call(value) === "[object Error]" - ); + return ops.op_is_native_error(value); } // deno-lint-ignore ban-types @@ -243,10 +215,7 @@ export function isBigIntObject(value: unknown): value is bigint { } export function isPromise(value: unknown): value is Promise<unknown> { - return ( - isObjectLike(value) && - value[Symbol.toStringTag] === "Promise" - ); + return ops.op_is_promise(value); } export function isProxy( @@ -256,11 +225,7 @@ export function isProxy( } export function isRegExp(value: unknown): value is RegExp { - return ( - isObjectLike(value) && - value[Symbol.toStringTag] === undefined && - _toString.call(value) === "[object RegExp]" - ); + return ops.op_is_reg_exp(value); } export function isSet(value: unknown): value is Set<unknown> { @@ -275,10 +240,7 @@ export function isSet(value: unknown): value is Set<unknown> { export function isSetIterator( value: unknown, ): value is IterableIterator<unknown> { - return ( - isObjectLike(value) && - value[Symbol.toStringTag] === "Set Iterator" - ); + return ops.op_is_set_iterator(value); } export function isSharedArrayBuffer( diff --git a/ext/node/polyfills/internal_binding/util.ts b/ext/node/polyfills/internal_binding/util.ts index 302b2d57c..a90728564 100644 --- a/ext/node/polyfills/internal_binding/util.ts +++ b/ext/node/polyfills/internal_binding/util.ts @@ -129,5 +129,3 @@ export function getOwnNonIndexProperties( } return result; } - -export { previewEntries } from "ext:deno_console/01_console.js"; diff --git a/ext/node/polyfills/util.ts b/ext/node/polyfills/util.ts index a77167253..c84131f68 100644 --- a/ext/node/polyfills/util.ts +++ b/ext/node/polyfills/util.ts @@ -109,15 +109,11 @@ export function isFunction(value: unknown): boolean { return typeof value === "function"; } -/** @deprecated Use util.types.RegExp() instead. */ -export function isRegExp(value: unknown): boolean { - return types.isRegExp(value); -} +/** @deprecated Use util.types.isRegExp() instead. */ +export const isRegExp = types.isRegExp; /** @deprecated Use util.types.isDate() instead. */ -export function isDate(value: unknown): boolean { - return types.isDate(value); -} +export const isDate = types.isDate; /** @deprecated - use `value === null || (typeof value !== "object" && typeof value !== "function")` instead. */ export function isPrimitive(value: unknown): boolean { |