Skip to content

Commit 86ab5b8

Browse files
committed
add missing node:util methods
1 parent c96bcc9 commit 86ab5b8

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

src/node/util.ts

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,28 @@ export function isArray(a: unknown): boolean {
221221
return Array.isArray(a);
222222
}
223223

224+
export function parseEnv(): void {
225+
// We don't implement this function yet because it is currently under
226+
// active development. We should implement it when it's stable
227+
throw new Error('node:util parseEnv is not implemented');
228+
}
229+
230+
export function getSystemErrorMap(): void {
231+
throw new Error('node:util getSystemErrorMap is not implemented');
232+
}
233+
234+
export function getSystemErrorName(): void {
235+
throw new Error('node:util getSystemErrorName is not implemented');
236+
}
237+
238+
export function getSystemErrorMessage(): void {
239+
throw new Error('node:util getSystemErrorMessage is not implemented');
240+
}
241+
242+
export function styleText(): void {
243+
throw new Error('node:util styleText is not implemented');
244+
}
245+
224246
export default {
225247
types,
226248
callbackify,
@@ -239,45 +261,20 @@ export default {
239261
debuglog,
240262
debug,
241263
deprecate,
264+
getSystemErrorMap,
265+
getSystemErrorMessage,
266+
getSystemErrorName,
242267
// Node.js originally exposed TextEncoder and TextDecoder off the util
243268
// module originally, so let's just go ahead and do the same.
244269
TextEncoder,
245270
TextDecoder,
246-
// We currently have no plans to implement the following APIs but we want
247-
// to provide throwing placeholders for them. We may eventually come back
248-
// around and implement these later.
249271
parseArgs,
272+
parseEnv,
273+
styleText,
250274
transferableAbortController,
251275
transferableAbortSignal,
252276
getCallSite,
253277
getCallSites,
254278
isDeepStrictEqual,
255279
isArray,
256280
};
257-
258-
// Node.js util APIs we're currently not supporting
259-
//
260-
// The following functions doesn't make sense for Workerd to support in runtime.
261-
// * util._errnoException
262-
// * util._exceptionWithHostPort
263-
// * util.getSystemErrorMap
264-
// * util.getSystemErrorName
265-
// * util.parseEnv
266-
// The following functions are removed from Node.js, and only supported using
267-
// a polyfill.
268-
// * util.isBoolean
269-
// * util.isBuffer
270-
// * util.isDate
271-
// * util.isError
272-
// * util.isFunction
273-
// * util.isNull
274-
// * util.isNullOrUndefined
275-
// * util.isNumber
276-
// * util.isObject
277-
// * util.isPrimitive
278-
// * util.isRegExp
279-
// * util.isString
280-
// * util.isSymbol
281-
// * util.isUndefined
282-
// TODO:
283-
// * util.styleText

0 commit comments

Comments
 (0)