mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Change __encoded__ to __enc__ for debug message encoding
This commit is contained in:
parent
5b76c91004
commit
3a1cc6a2be
@ -276,7 +276,7 @@ RED.clipboard = (function() {
|
|||||||
if (typeof value !== "string" ) {
|
if (typeof value !== "string" ) {
|
||||||
value = JSON.stringify(value, function(key,value) {
|
value = JSON.stringify(value, function(key,value) {
|
||||||
if (value !== null && typeof value === 'object') {
|
if (value !== null && typeof value === 'object') {
|
||||||
if (value.__encoded__) {
|
if (value.__enc__) {
|
||||||
if (value.hasOwnProperty('data') && value.hasOwnProperty('length')) {
|
if (value.hasOwnProperty('data') && value.hasOwnProperty('length')) {
|
||||||
truncated = value.data.length !== value.length;
|
truncated = value.data.length !== value.length;
|
||||||
return value.data;
|
return value.data;
|
||||||
|
@ -298,17 +298,17 @@ RED.utils = (function() {
|
|||||||
|
|
||||||
var isArray = Array.isArray(obj);
|
var isArray = Array.isArray(obj);
|
||||||
var isArrayObject = false;
|
var isArrayObject = false;
|
||||||
if (obj && typeof obj === 'object' && obj.hasOwnProperty('type') && obj.hasOwnProperty('data') && ((obj.__encoded__ && obj.type === 'array') || obj.type === 'Buffer')) {
|
if (obj && typeof obj === 'object' && obj.hasOwnProperty('type') && obj.hasOwnProperty('data') && ((obj.__enc__ && obj.type === 'array') || obj.type === 'Buffer')) {
|
||||||
isArray = true;
|
isArray = true;
|
||||||
isArrayObject = true;
|
isArrayObject = true;
|
||||||
}
|
}
|
||||||
if (obj === null || obj === undefined) {
|
if (obj === null || obj === undefined) {
|
||||||
$('<span class="debug-message-type-null">'+obj+'</span>').appendTo(entryObj);
|
$('<span class="debug-message-type-null">'+obj+'</span>').appendTo(entryObj);
|
||||||
} else if (obj.__encoded__ && obj.type === 'number') {
|
} else if (obj.__enc__ && obj.type === 'number') {
|
||||||
e = $('<span class="debug-message-type-number debug-message-object-header"></span>').text(obj.data).appendTo(entryObj);
|
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')) {
|
} else if (typeHint === "function" || (obj.__enc__ && obj.type === 'function')) {
|
||||||
e = $('<span class="debug-message-type-meta debug-message-object-header"></span>').text("function").appendTo(entryObj);
|
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')) {
|
} else if (typeHint === "internal" || (obj.__enc__ && obj.type === 'internal')) {
|
||||||
e = $('<span class="debug-message-type-meta debug-message-object-header"></span>').text("[internal]").appendTo(entryObj);
|
e = $('<span class="debug-message-type-meta debug-message-object-header"></span>').text("[internal]").appendTo(entryObj);
|
||||||
} else if (typeof obj === 'string') {
|
} else if (typeof obj === 'string') {
|
||||||
if (/[\t\n\r]/.test(obj)) {
|
if (/[\t\n\r]/.test(obj)) {
|
||||||
@ -354,7 +354,7 @@ RED.utils = (function() {
|
|||||||
if (originalLength === undefined) {
|
if (originalLength === undefined) {
|
||||||
originalLength = data.length;
|
originalLength = data.length;
|
||||||
}
|
}
|
||||||
if (data.__encoded__) {
|
if (data.__enc__) {
|
||||||
data = data.data;
|
data = data.data;
|
||||||
}
|
}
|
||||||
type = obj.type.toLowerCase();
|
type = obj.type.toLowerCase();
|
||||||
|
@ -494,7 +494,7 @@ function encodeObject(msg,opts) {
|
|||||||
if (msg.msg.length > debuglength) {
|
if (msg.msg.length > debuglength) {
|
||||||
// msg.msg = msg.msg.slice(0,debuglength);
|
// msg.msg = msg.msg.slice(0,debuglength);
|
||||||
msg.msg = {
|
msg.msg = {
|
||||||
__encoded__: true,
|
__enc__: true,
|
||||||
type: "array",
|
type: "array",
|
||||||
data: msg.msg.slice(0,debuglength),
|
data: msg.msg.slice(0,debuglength),
|
||||||
length: msg.msg.length
|
length: msg.msg.length
|
||||||
@ -505,14 +505,14 @@ function encodeObject(msg,opts) {
|
|||||||
msg.msg = safeJSONStringify(msg.msg, function(key, value) {
|
msg.msg = safeJSONStringify(msg.msg, function(key, value) {
|
||||||
if (key === '_req' || key === '_res') {
|
if (key === '_req' || key === '_res') {
|
||||||
value = {
|
value = {
|
||||||
__encoded__: true,
|
__enc__: true,
|
||||||
type: "internal"
|
type: "internal"
|
||||||
}
|
}
|
||||||
} else if (value instanceof Error) {
|
} else if (value instanceof Error) {
|
||||||
value = value.toString()
|
value = value.toString()
|
||||||
} else if (util.isArray(value) && value.length > debuglength) {
|
} else if (util.isArray(value) && value.length > debuglength) {
|
||||||
value = {
|
value = {
|
||||||
__encoded__: true,
|
__enc__: true,
|
||||||
type: "array",
|
type: "array",
|
||||||
data: value.slice(0,debuglength),
|
data: value.slice(0,debuglength),
|
||||||
length: value.length
|
length: value.length
|
||||||
@ -523,20 +523,20 @@ function encodeObject(msg,opts) {
|
|||||||
}
|
}
|
||||||
} else if (typeof value === 'function') {
|
} else if (typeof value === 'function') {
|
||||||
value = {
|
value = {
|
||||||
__encoded__: true,
|
__enc__: true,
|
||||||
type: "function"
|
type: "function"
|
||||||
}
|
}
|
||||||
} else if (typeof value === 'number') {
|
} else if (typeof value === 'number') {
|
||||||
if (isNaN(value) || value === Infinity || value === -Infinity) {
|
if (isNaN(value) || value === Infinity || value === -Infinity) {
|
||||||
value = {
|
value = {
|
||||||
__encoded__: true,
|
__enc__: true,
|
||||||
type: "number",
|
type: "number",
|
||||||
data: value.toString()
|
data: value.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (value && value.constructor) {
|
} else if (value && value.constructor) {
|
||||||
if (value.type === "Buffer") {
|
if (value.type === "Buffer") {
|
||||||
value.__encoded__ = true;
|
value.__enc__ = true;
|
||||||
value.length = value.data.length;
|
value.length = value.data.length;
|
||||||
if (value.length > debuglength) {
|
if (value.length > debuglength) {
|
||||||
value.data = value.data.slice(0,debuglength);
|
value.data = value.data.slice(0,debuglength);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user