1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Support bigint types in Debug sidebar

This commit is contained in:
Nick O'Leary 2020-11-17 20:50:29 +00:00
parent f19ec5d9b6
commit 545dda166f
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
3 changed files with 18 additions and 2 deletions

View File

@ -773,6 +773,9 @@ RED.clipboard = (function() {
// representation or null
return null;
}
if (value.type === 'bigint') {
return value.data.toString();
}
if (value.type === 'undefined') {
return undefined;
}

View File

@ -60,7 +60,7 @@ RED.utils = (function() {
result = $('<span class="red-ui-debug-msg-object-value red-ui-debug-msg-type-meta"></span>').text('array['+value.length+']');
} else if (value.hasOwnProperty('type') && value.type === 'function') {
result = $('<span class="red-ui-debug-msg-object-value red-ui-debug-msg-type-meta"></span>').text('function');
} else if (value.hasOwnProperty('type') && value.type === 'number') {
} else if (value.hasOwnProperty('type') && (value.type === 'number' || value.type === 'bigint')) {
result = $('<span class="red-ui-debug-msg-object-value red-ui-debug-msg-type-number"></span>').text(value.data);
} else {
result = $('<span class="red-ui-debug-msg-object-value red-ui-debug-msg-type-meta">object</span>');
@ -352,7 +352,7 @@ RED.utils = (function() {
$('<span class="red-ui-debug-msg-type-null">'+obj+'</span>').appendTo(entryObj);
} else if (obj.__enc__ && obj.type === 'undefined') {
$('<span class="red-ui-debug-msg-type-null">undefined</span>').appendTo(entryObj);
} else if (obj.__enc__ && obj.type === 'number') {
} else if (obj.__enc__ && (obj.type === 'number' || obj.type === 'bigint')) {
e = $('<span class="red-ui-debug-msg-type-number red-ui-debug-msg-object-header"></span>').text(obj.data).appendTo(entryObj);
} else if (typeHint === "function" || (obj.__enc__ && obj.type === 'function')) {
e = $('<span class="red-ui-debug-msg-type-meta red-ui-debug-msg-object-header"></span>').text("function").appendTo(entryObj);

View File

@ -774,6 +774,12 @@ function encodeObject(msg,opts) {
data: value.toString()
}
}
} else if (typeof value === 'bigint') {
value = {
__enc__: true,
type: 'bigint',
data: value.toString()
}
} else if (value && value.constructor) {
if (value.type === "Buffer") {
value.__enc__ = true;
@ -808,6 +814,13 @@ function encodeObject(msg,opts) {
} else if (msgType === "number") {
msg.format = "number";
msg.msg = msg.msg.toString();
} else if (msgType === "bigint") {
msg.format = "bigint";
msg.msg = {
__enc__: true,
type: 'bigint',
data: msg.msg.toString()
};
} else if (msg.msg === null || msgType === "undefined") {
msg.format = (msg.msg === null)?"null":"undefined";
msg.msg = "(undefined)";