@node-red/util 4.1.0-beta.2 → 4.1.1

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/exec.js CHANGED
@@ -57,7 +57,15 @@ module.exports = {
57
57
  return new Promise((resolve, reject) => {
58
58
  let stdout = "";
59
59
  let stderr = "";
60
- const child = child_process.spawn(command,args,options);
60
+ let child
61
+ if (args && options.shell) {
62
+ // If we are using a shell, we need to join the args into a single string
63
+ // as passing a separate array of args is deprecated in Node 24
64
+ command = [command].concat(args).join(" ");
65
+ child = child_process.spawn(command, options)
66
+ } else {
67
+ child = child_process.spawn(command, args, options);
68
+ }
61
69
  child.stdout.on('data', (data) => {
62
70
  const str = ""+data;
63
71
  stdout += str;
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
- var needsStringify = isArray;
881
- if (isArray) {
882
- msg.format = "array["+msg.msg.length+"]";
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: "array",
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") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/util",
3
- "version": "4.1.0-beta.2",
3
+ "version": "4.1.1",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",