|
1 | | -import { |
2 | | - type InspectParameterFn, |
3 | | - defaultInspect, |
4 | | - isAnyArrayBuffer, |
5 | | - isUint8Array |
6 | | -} from './parser/utils'; |
| 1 | +import { type InspectFn, defaultInspect, isAnyArrayBuffer, isUint8Array } from './parser/utils'; |
7 | 2 | import type { EJSONOptions } from './extended_json'; |
8 | 3 | import { BSONError } from './error'; |
9 | 4 | import { BSON_BINARY_SUBTYPE_UUID_NEW } from './constants'; |
@@ -268,15 +263,11 @@ export class Binary extends BSONValue { |
268 | 263 | return type === BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new Binary(data, type); |
269 | 264 | } |
270 | 265 |
|
271 | | - inspect(depth?: number, options?: unknown, inspect?: InspectParameterFn): string { |
272 | | - const addQuotes = !inspect; |
| 266 | + inspect(depth?: number, options?: unknown, inspect?: InspectFn): string { |
273 | 267 | inspect ??= defaultInspect; |
274 | 268 | const base64 = ByteUtils.toBase64(this.buffer.subarray(0, this.position)); |
275 | 269 | const base64Arg = inspect(base64, options); |
276 | 270 | const subTypeArg = inspect(this.sub_type, options); |
277 | | - if (addQuotes) { |
278 | | - return `Binary.createFromBase64('${base64Arg}', ${subTypeArg})`; |
279 | | - } |
280 | 271 | return `Binary.createFromBase64(${base64Arg}, ${subTypeArg})`; |
281 | 272 | } |
282 | 273 | } |
@@ -472,12 +463,8 @@ export class UUID extends Binary { |
472 | 463 | * @returns return the 36 character hex string representation. |
473 | 464 | * |
474 | 465 | */ |
475 | | - inspect(depth?: number, options?: unknown, inspect?: InspectParameterFn): string { |
476 | | - const addQuotes = !inspect; |
| 466 | + inspect(depth?: number, options?: unknown, inspect?: InspectFn): string { |
477 | 467 | inspect ??= defaultInspect; |
478 | | - if (addQuotes) { |
479 | | - return `new UUID('${inspect(this.toHexString(), options)}')`; |
480 | | - } |
481 | 468 | return `new UUID(${inspect(this.toHexString(), options)})`; |
482 | 469 | } |
483 | 470 | } |
0 commit comments