Skip to content

Commit 576d931

Browse files
authored
Use builtin implementation for isArray and isDeepStrictEqual (#7998)
1 parent 504354b commit 576d931

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

.changeset/lazy-windows-provide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/unenv-preset": patch
3+
---
4+
5+
Use builtin implementation for isArray and isDeepStrictEqual

packages/unenv-preset/src/runtime/node/util/index.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import {
44
_exceptionWithHostPort,
55
getSystemErrorMap,
66
getSystemErrorName,
7-
isArray,
87
isBoolean,
98
isBuffer,
109
isDate,
11-
isDeepStrictEqual,
1210
isError,
1311
isFunction,
1412
isNull,
@@ -30,11 +28,9 @@ export {
3028
_exceptionWithHostPort,
3129
getSystemErrorMap,
3230
getSystemErrorName,
33-
isArray,
3431
isBoolean,
3532
isBuffer,
3633
isDate,
37-
isDeepStrictEqual,
3834
isError,
3935
isFunction,
4036
isNull,
@@ -71,6 +67,8 @@ export const {
7167
getCallSite,
7268
inherits,
7369
inspect,
70+
isArray,
71+
isDeepStrictEqual,
7472
log,
7573
parseArgs,
7674
promisify,
@@ -91,11 +89,9 @@ export default {
9189
_exceptionWithHostPort,
9290
getSystemErrorMap,
9391
getSystemErrorName,
94-
isArray,
9592
isBoolean,
9693
isBuffer,
9794
isDate,
98-
isDeepStrictEqual,
9995
isError,
10096
isFunction,
10197
isNull,
@@ -113,10 +109,6 @@ export default {
113109
/**
114110
* manually unroll workerd-polyfilled-symbols to make it tree-shakeable
115111
*/
116-
MIMEParams,
117-
MIMEType,
118-
TextDecoder,
119-
TextEncoder,
120112
_extend,
121113
aborted,
122114
callbackify,
@@ -128,10 +120,16 @@ export default {
128120
getCallSite,
129121
inherits,
130122
inspect,
123+
isArray,
124+
isDeepStrictEqual,
131125
log,
126+
MIMEParams,
127+
MIMEType,
132128
parseArgs,
133129
promisify,
134130
stripVTControlCharacters,
131+
TextDecoder,
132+
TextEncoder,
135133
toUSVString,
136134
transferableAbortController,
137135
transferableAbortSignal,

packages/unenv-preset/tests/worker/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,12 @@ async function testNodeCompatModules() {
109109
}
110110

111111
async function testUtilImplements() {
112-
const { types } = await import("node:util");
112+
const util = await import("node:util");
113+
const { types } = util;
113114
assert.strictEqual(types.isExternal("hello world"), false);
114115
assert.strictEqual(types.isAnyArrayBuffer(new ArrayBuffer(0)), true);
116+
assert.strictEqual(util.isArray([]), true);
117+
assert.strictEqual(util.isDeepStrictEqual(0, 0), true);
115118
}
116119

117120
async function testPath() {

0 commit comments

Comments
 (0)