@node-red/util 4.1.0 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/util.js +23 -4
- package/package.json +1 -1
package/lib/util.js
CHANGED
|
@@ -877,14 +877,16 @@ function encodeObject(msg,opts) {
|
|
|
877
877
|
});
|
|
878
878
|
} else {
|
|
879
879
|
var isArray = Array.isArray(msg.msg);
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
880
|
+
const isTypedArray = ArrayBuffer.isView(msg.msg);
|
|
881
|
+
var needsStringify = isArray || isTypedArray;
|
|
882
|
+
var typeName = isArray ? 'array' : constructorName(msg.msg);
|
|
883
|
+
if (isArray || isTypedArray) {
|
|
884
|
+
msg.format = typeName + "["+msg.msg.length+"]";
|
|
883
885
|
if (msg.msg.length > debuglength) {
|
|
884
886
|
// msg.msg = msg.msg.slice(0,debuglength);
|
|
885
887
|
msg.msg = {
|
|
886
888
|
__enc__: true,
|
|
887
|
-
type:
|
|
889
|
+
type: typeName,
|
|
888
890
|
data: msg.msg.slice(0,debuglength),
|
|
889
891
|
length: msg.msg.length
|
|
890
892
|
}
|
|
@@ -948,6 +950,16 @@ function encodeObject(msg,opts) {
|
|
|
948
950
|
data: value.slice(0,debuglength),
|
|
949
951
|
length: value.length
|
|
950
952
|
}
|
|
953
|
+
} else if (ArrayBuffer.isView(value) && value.length > debuglength && !Buffer.isBuffer(value)) { // include typed arrays, exclude Buffer
|
|
954
|
+
// Note: Buffer is a subclass of Uint8Array
|
|
955
|
+
const typeName = constructorName(value);
|
|
956
|
+
/** @type {ArrayBufferView} */
|
|
957
|
+
value = {
|
|
958
|
+
__enc__: true,
|
|
959
|
+
type: typeName,
|
|
960
|
+
data: Array.from(value).slice(0,debuglength),
|
|
961
|
+
length: value.length
|
|
962
|
+
}
|
|
951
963
|
} else if (typeof value === 'string') {
|
|
952
964
|
if (value.length > debuglength) {
|
|
953
965
|
value = value.substring(0,debuglength)+"...";
|
|
@@ -978,6 +990,13 @@ function encodeObject(msg,opts) {
|
|
|
978
990
|
if (value.length > debuglength) {
|
|
979
991
|
value.data = value.data.slice(0,debuglength);
|
|
980
992
|
}
|
|
993
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
994
|
+
value = {
|
|
995
|
+
__enc__: true,
|
|
996
|
+
type: "array",
|
|
997
|
+
data: Array.from(value),
|
|
998
|
+
length: value.length
|
|
999
|
+
}
|
|
981
1000
|
} else if (constructorName(value) === "ServerResponse") {
|
|
982
1001
|
value = "[internal]"
|
|
983
1002
|
} else if (constructorName(value) === "Socket") {
|