From 7c6479e28fc251d1c0c0aa16f06dbe56fba3afc1 Mon Sep 17 00:00:00 2001 From: kyraNET Date: Sat, 1 Dec 2018 01:59:41 +0100 Subject: [PATCH] feat: Support for bigints in console --- js/console.ts | 2 ++ js/console_test.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/js/console.ts b/js/console.ts index 6e0b2e7a6a..ccfcf007b8 100644 --- a/js/console.ts +++ b/js/console.ts @@ -105,6 +105,8 @@ function stringify( case "undefined": case "symbol": return String(value); + case "bigint": + return `${value}n`; case "function": return createFunctionString(value as Function, ctx); case "object": diff --git a/js/console_test.ts b/js/console_test.ts index 3a50b08d45..a46edf29e7 100644 --- a/js/console_test.ts +++ b/js/console_test.ts @@ -70,6 +70,7 @@ test(function consoleTestStringifyCircular() { const nestedObjExpected = `{ num: 1, bool: true, str: "a", method: [Function: method], asyncMethod: [AsyncFunction: asyncMethod], generatorMethod: [GeneratorFunction: generatorMethod], un: undefined, nu: null, arrowFunc: [Function: arrowFunc], extendedClass: Extended { a: 1, b: 2 }, nFunc: [Function], extendedCstr: [Function: Extended], o: { num: 2, bool: false, str: "b", method: [Function: method], un: undefined, nu: null, nested: [Circular], emptyObj: [object], arr: [object], baseClass: [object] } }`; assertEqual(stringify(1), "1"); + assertEqual(stringify(1n), "1n"); assertEqual(stringify("s"), "s"); assertEqual(stringify(false), "false"); assertEqual(stringify(Symbol(1)), "Symbol(1)");