mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
466cb4be89
commit
cdb173fd6e
@ -276,10 +276,21 @@ RED.clipboard = (function() {
|
||||
if (typeof value !== "string" ) {
|
||||
value = JSON.stringify(value, function(key,value) {
|
||||
if (value !== null && typeof value === 'object') {
|
||||
if (value.__encoded__ && value.hasOwnProperty('data') && value.hasOwnProperty('length')) {
|
||||
if (value.__encoded__) {
|
||||
if (value.hasOwnProperty('data') && value.hasOwnProperty('length')) {
|
||||
truncated = value.data.length !== value.length;
|
||||
return value.data;
|
||||
}
|
||||
if (value.type === 'function' || value.type === 'internal') {
|
||||
return undefined
|
||||
}
|
||||
if (value.type === 'number') {
|
||||
// Handle NaN and Infinity - they are not permitted
|
||||
// in JSON. We can either substitute with a String
|
||||
// representation or null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
@ -36,6 +36,8 @@ RED.utils = (function() {
|
||||
result = $('<span class="debug-message-object-value debug-message-type-meta"></span>').text('array['+value.length+']');
|
||||
} else if (value.hasOwnProperty('type') && value.type === 'function') {
|
||||
result = $('<span class="debug-message-object-value debug-message-type-meta"></span>').text('function');
|
||||
} else if (value.hasOwnProperty('type') && value.type === 'number') {
|
||||
result = $('<span class="debug-message-object-value debug-message-type-number"></span>').text(value.data);
|
||||
} else {
|
||||
result = $('<span class="debug-message-object-value debug-message-type-meta">object</span>');
|
||||
}
|
||||
@ -47,6 +49,8 @@ RED.utils = (function() {
|
||||
subvalue = sanitize(value);
|
||||
}
|
||||
result = $('<span class="debug-message-object-value debug-message-type-string"></span>').html('"'+formatString(subvalue)+'"');
|
||||
} else if (typeof value === 'number') {
|
||||
result = $('<span class="debug-message-object-value debug-message-type-number"></span>').text(""+value);
|
||||
} else {
|
||||
result = $('<span class="debug-message-object-value debug-message-type-other"></span>').text(""+value);
|
||||
}
|
||||
@ -300,6 +304,8 @@ RED.utils = (function() {
|
||||
}
|
||||
if (obj === null || obj === undefined) {
|
||||
$('<span class="debug-message-type-null">'+obj+'</span>').appendTo(entryObj);
|
||||
} else if (obj.__encoded__ && obj.type === 'number') {
|
||||
e = $('<span class="debug-message-type-number debug-message-object-header"></span>').text(obj.data).appendTo(entryObj);
|
||||
} else if (typeHint === "function" || (obj.__encoded__ && obj.type === 'function')) {
|
||||
e = $('<span class="debug-message-type-meta debug-message-object-header"></span>').text("function").appendTo(entryObj);
|
||||
} else if (typeHint === "internal" || (obj.__encoded__ && obj.type === 'internal')) {
|
||||
@ -799,6 +805,10 @@ RED.utils = (function() {
|
||||
function decodeObject(payload,format) {
|
||||
if ((format === 'number') && (payload === "NaN")) {
|
||||
payload = Number.NaN;
|
||||
} else if ((format === 'number') && (payload === "Infinity")) {
|
||||
payload = Infinity;
|
||||
} else if ((format === 'number') && (payload === "-Infinity")) {
|
||||
payload = -Infinity;
|
||||
} else if (format === 'Object' || /^array/.test(format) || format === 'boolean' || format === 'number' ) {
|
||||
payload = JSON.parse(payload);
|
||||
} else if (/error/i.test(format)) {
|
||||
|
@ -469,6 +469,14 @@ function encodeObject(msg,opts) {
|
||||
__encoded__: true,
|
||||
type: "function"
|
||||
}
|
||||
} else if (typeof value === 'number') {
|
||||
if (isNaN(value) || value === Infinity || value === -Infinity) {
|
||||
value = {
|
||||
__encoded__: true,
|
||||
type: "number",
|
||||
data: value.toString()
|
||||
}
|
||||
}
|
||||
} else if (value && value.constructor) {
|
||||
if (value.type === "Buffer") {
|
||||
value.__encoded__ = true;
|
||||
|
Loading…
Reference in New Issue
Block a user