|
1 | | -import { isAnyArrayBuffer, isUint8Array } from './parser/utils'; |
| 1 | +import { type InspectFn, defaultInspect, isAnyArrayBuffer, isUint8Array } from './parser/utils'; |
2 | 2 | import type { EJSONOptions } from './extended_json'; |
3 | 3 | import { BSONError } from './error'; |
4 | 4 | import { BSON_BINARY_SUBTYPE_UUID_NEW } from './constants'; |
@@ -263,14 +263,12 @@ export class Binary extends BSONValue { |
263 | 263 | return type === BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new Binary(data, type); |
264 | 264 | } |
265 | 265 |
|
266 | | - /** @internal */ |
267 | | - [Symbol.for('nodejs.util.inspect.custom')](): string { |
268 | | - return this.inspect(); |
269 | | - } |
270 | | - |
271 | | - inspect(): string { |
| 266 | + inspect(depth?: number, options?: unknown, inspect?: InspectFn): string { |
| 267 | + inspect ??= defaultInspect; |
272 | 268 | const base64 = ByteUtils.toBase64(this.buffer.subarray(0, this.position)); |
273 | | - return `Binary.createFromBase64("${base64}", ${this.sub_type})`; |
| 269 | + const base64Arg = inspect(base64, options); |
| 270 | + const subTypeArg = inspect(this.sub_type, options); |
| 271 | + return `Binary.createFromBase64(${base64Arg}, ${subTypeArg})`; |
274 | 272 | } |
275 | 273 | } |
276 | 274 |
|
@@ -463,13 +461,10 @@ export class UUID extends Binary { |
463 | 461 | * Converts to a string representation of this Id. |
464 | 462 | * |
465 | 463 | * @returns return the 36 character hex string representation. |
466 | | - * @internal |
| 464 | + * |
467 | 465 | */ |
468 | | - [Symbol.for('nodejs.util.inspect.custom')](): string { |
469 | | - return this.inspect(); |
470 | | - } |
471 | | - |
472 | | - inspect(): string { |
473 | | - return `new UUID("${this.toHexString()}")`; |
| 466 | + inspect(depth?: number, options?: unknown, inspect?: InspectFn): string { |
| 467 | + inspect ??= defaultInspect; |
| 468 | + return `new UUID(${inspect(this.toHexString(), options)})`; |
474 | 469 | } |
475 | 470 | } |
0 commit comments