unetjs 2.0.2 → 2.0.5

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/dist/cjs/unet.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /* unet.js v2.0.2 2022-06-10T03:18:03.319Z */
1
+ /* unet.js v2.0.5 2022-06-15T07:40:54.241Z */
2
2
 
3
3
  'use strict';
4
4
 
@@ -22,30 +22,32 @@ function _interopNamespace(e) {
22
22
  return Object.freeze(n);
23
23
  }
24
24
 
25
- /* fjage.js v1.9.1-rc6 */
25
+ /* fjage.js v1.10.1 */
26
26
 
27
- /* global window self */
27
+ const isBrowser =
28
+ typeof window !== "undefined" && typeof window.document !== "undefined";
28
29
 
29
- const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
30
+ const isNode =
31
+ typeof process !== "undefined" &&
32
+ process.versions != null &&
33
+ process.versions.node != null;
30
34
 
31
- /* eslint-disable no-restricted-globals */
32
- const isWebWorker = typeof self === 'object'
33
- && self.constructor
34
- && self.constructor.name === 'DedicatedWorkerGlobalScope';
35
- /* eslint-enable no-restricted-globals */
36
-
37
- const isNode = typeof process !== 'undefined'
38
- && process.versions != null
39
- && process.versions.node != null;
35
+ const isWebWorker =
36
+ typeof self === "object" &&
37
+ self.constructor &&
38
+ self.constructor.name === "DedicatedWorkerGlobalScope";
40
39
 
41
40
  /**
42
41
  * @see https://github.com/jsdom/jsdom/releases/tag/12.0.0
43
42
  * @see https://github.com/jsdom/jsdom/issues/1537
44
43
  */
45
- /* eslint-disable no-undef */
46
- const isJsDom = () => (typeof window !== 'undefined' && window.name === 'nodejs')
47
- || navigator.userAgent.includes('Node.js')
48
- || navigator.userAgent.includes('jsdom');
44
+ const isJsDom =
45
+ (typeof window !== "undefined" && window.name === "nodejs") ||
46
+ (typeof navigator !== "undefined" &&
47
+ (navigator.userAgent.includes("Node.js") ||
48
+ navigator.userAgent.includes("jsdom")));
49
+
50
+ typeof Deno !== "undefined" && typeof Deno.core !== "undefined";
49
51
 
50
52
  const SOCKET_OPEN = 'open';
51
53
  const SOCKET_OPENING = 'opening';
@@ -641,9 +643,9 @@ class Message {
641
643
 
642
644
  /**
643
645
  * A gateway for connecting to a fjage master container. The new version of the constructor
644
- * uses an options object instead of individual parameters. The old version with
645
- *
646
- *
646
+ * uses an options object instead of individual parameters. The old version with
647
+ *
648
+ *
647
649
  * @class
648
650
  * @param {Object} opts
649
651
  * @param {string} [opts.hostname="localhost"] - hostname/ip address of the master container to connect to
@@ -664,7 +666,7 @@ class Gateway {
664
666
  if (typeof opts === 'string' || opts instanceof String){
665
667
  opts = {
666
668
  'hostname': opts,
667
- 'port' : port || gObj.location.port,
669
+ 'port' : port || gObj.location.port,
668
670
  'pathname' : pathname,
669
671
  'timeout' : timeout
670
672
  };
@@ -833,7 +835,7 @@ class Gateway {
833
835
  return 'inReplyTo' in msg && msg.inReplyTo == filter;
834
836
  } else if (Object.prototype.hasOwnProperty.call(filter, 'msgID')) {
835
837
  return 'inReplyTo' in msg && msg.inReplyTo == filter.msgID;
836
- } else if (filter.__proto__.name == 'Message') {
838
+ } else if (filter.__proto__.name == 'Message' || filter.__proto__.__proto__.name == 'Message') {
837
839
  return filter.__clazz__ == msg.__clazz__;
838
840
  } else if (typeof filter == 'function') {
839
841
  return filter(msg);
@@ -860,13 +862,13 @@ class Gateway {
860
862
  if (f.length ) return f[0];
861
863
  return null;
862
864
  }
863
-
865
+
864
866
  /** @private */
865
867
  _addGWCache(gw){
866
868
  if (!gObj.fjage || !gObj.fjage.gateways) return;
867
869
  gObj.fjage.gateways.push(gw);
868
870
  }
869
-
871
+
870
872
  /** @private */
871
873
  _removeGWCache(gw){
872
874
  if (!gObj.fjage || !gObj.fjage.gateways) return;
@@ -1069,7 +1071,7 @@ class Gateway {
1069
1071
  }
1070
1072
 
1071
1073
  /**
1072
- * Sends a request and waits for a response. This method returns a {Promise} which resolves when a response
1074
+ * Sends a request and waits for a response. This method returns a {Promise} which resolves when a response
1073
1075
  * is received or if no response is received after the timeout.
1074
1076
  *
1075
1077
  * @param {string} msg - message to send
@@ -1082,10 +1084,10 @@ class Gateway {
1082
1084
  }
1083
1085
 
1084
1086
  /**
1085
- * Returns a response message received by the gateway. This method returns a {Promise} which resolves when
1087
+ * Returns a response message received by the gateway. This method returns a {Promise} which resolves when
1086
1088
  * a response is received or if no response is received after the timeout.
1087
1089
  *
1088
- * @param {function} [filter=] - original message to which a response is expected, or a MessageClass of the type
1090
+ * @param {function} [filter=] - original message to which a response is expected, or a MessageClass of the type
1089
1091
  * of message to match, or a closure to use to match against the message
1090
1092
  * @param {number} [timeout=0] - timeout in milliseconds
1091
1093
  * @returns {Promise<?Message>} - received response message, null on timeout
@@ -1145,7 +1147,7 @@ const Services = {
1145
1147
  * @param {string} name - fully qualified name of the message class to be created
1146
1148
  * @param {class} [parent=Message] - class of the parent MessageClass to inherit from
1147
1149
  * @returns {function} - constructor for the unqualified message class
1148
- * @example
1150
+ * @example
1149
1151
  * const ParameterReq = MessageClass('org.arl.fjage.param.ParameterReq');
1150
1152
  * let pReq = new ParameterReq()
1151
1153
  */
@@ -1182,7 +1184,7 @@ function _guid(len) {
1182
1184
  s += s4();
1183
1185
  return s;
1184
1186
  }
1185
-
1187
+
1186
1188
  // convert from base 64 to array
1187
1189
  /** @private */
1188
1190
  function _b64toArray(base64, dtype, littleEndian=true) {
@@ -1553,7 +1555,9 @@ class CachingAgentID extends AgentID {
1553
1555
  if (this.greedy && !(Array.isArray(params) && params.includes('name')) && params != 'name') {
1554
1556
  let rsp = await super.get(null, index, timeout);
1555
1557
  this._updateCache(null, rsp, index);
1556
- if (Array.isArray(params)) {
1558
+ if (!rsp) return Array.isArray(params) ? new Array(params.length).fill(null) : null;
1559
+ if (!params) return rsp;
1560
+ else if (Array.isArray(params)) {
1557
1561
  return params.map(p => {
1558
1562
  let f = Object.keys(rsp).find(rv => this._toNamed(rv) === p);
1559
1563
  return f ? rsp[f] : null;
package/dist/esm/unet.js CHANGED
@@ -1,29 +1,31 @@
1
- /* unet.js v2.0.2 2022-06-10T03:18:03.319Z */
1
+ /* unet.js v2.0.5 2022-06-15T07:40:54.241Z */
2
2
 
3
- /* fjage.js v1.9.1-rc6 */
3
+ /* fjage.js v1.10.1 */
4
4
 
5
- /* global window self */
5
+ const isBrowser =
6
+ typeof window !== "undefined" && typeof window.document !== "undefined";
6
7
 
7
- const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
8
+ const isNode =
9
+ typeof process !== "undefined" &&
10
+ process.versions != null &&
11
+ process.versions.node != null;
8
12
 
9
- /* eslint-disable no-restricted-globals */
10
- const isWebWorker = typeof self === 'object'
11
- && self.constructor
12
- && self.constructor.name === 'DedicatedWorkerGlobalScope';
13
- /* eslint-enable no-restricted-globals */
14
-
15
- const isNode = typeof process !== 'undefined'
16
- && process.versions != null
17
- && process.versions.node != null;
13
+ const isWebWorker =
14
+ typeof self === "object" &&
15
+ self.constructor &&
16
+ self.constructor.name === "DedicatedWorkerGlobalScope";
18
17
 
19
18
  /**
20
19
  * @see https://github.com/jsdom/jsdom/releases/tag/12.0.0
21
20
  * @see https://github.com/jsdom/jsdom/issues/1537
22
21
  */
23
- /* eslint-disable no-undef */
24
- const isJsDom = () => (typeof window !== 'undefined' && window.name === 'nodejs')
25
- || navigator.userAgent.includes('Node.js')
26
- || navigator.userAgent.includes('jsdom');
22
+ const isJsDom =
23
+ (typeof window !== "undefined" && window.name === "nodejs") ||
24
+ (typeof navigator !== "undefined" &&
25
+ (navigator.userAgent.includes("Node.js") ||
26
+ navigator.userAgent.includes("jsdom")));
27
+
28
+ typeof Deno !== "undefined" && typeof Deno.core !== "undefined";
27
29
 
28
30
  const SOCKET_OPEN = 'open';
29
31
  const SOCKET_OPENING = 'opening';
@@ -619,9 +621,9 @@ class Message {
619
621
 
620
622
  /**
621
623
  * A gateway for connecting to a fjage master container. The new version of the constructor
622
- * uses an options object instead of individual parameters. The old version with
623
- *
624
- *
624
+ * uses an options object instead of individual parameters. The old version with
625
+ *
626
+ *
625
627
  * @class
626
628
  * @param {Object} opts
627
629
  * @param {string} [opts.hostname="localhost"] - hostname/ip address of the master container to connect to
@@ -642,7 +644,7 @@ class Gateway {
642
644
  if (typeof opts === 'string' || opts instanceof String){
643
645
  opts = {
644
646
  'hostname': opts,
645
- 'port' : port || gObj.location.port,
647
+ 'port' : port || gObj.location.port,
646
648
  'pathname' : pathname,
647
649
  'timeout' : timeout
648
650
  };
@@ -811,7 +813,7 @@ class Gateway {
811
813
  return 'inReplyTo' in msg && msg.inReplyTo == filter;
812
814
  } else if (Object.prototype.hasOwnProperty.call(filter, 'msgID')) {
813
815
  return 'inReplyTo' in msg && msg.inReplyTo == filter.msgID;
814
- } else if (filter.__proto__.name == 'Message') {
816
+ } else if (filter.__proto__.name == 'Message' || filter.__proto__.__proto__.name == 'Message') {
815
817
  return filter.__clazz__ == msg.__clazz__;
816
818
  } else if (typeof filter == 'function') {
817
819
  return filter(msg);
@@ -838,13 +840,13 @@ class Gateway {
838
840
  if (f.length ) return f[0];
839
841
  return null;
840
842
  }
841
-
843
+
842
844
  /** @private */
843
845
  _addGWCache(gw){
844
846
  if (!gObj.fjage || !gObj.fjage.gateways) return;
845
847
  gObj.fjage.gateways.push(gw);
846
848
  }
847
-
849
+
848
850
  /** @private */
849
851
  _removeGWCache(gw){
850
852
  if (!gObj.fjage || !gObj.fjage.gateways) return;
@@ -1047,7 +1049,7 @@ class Gateway {
1047
1049
  }
1048
1050
 
1049
1051
  /**
1050
- * Sends a request and waits for a response. This method returns a {Promise} which resolves when a response
1052
+ * Sends a request and waits for a response. This method returns a {Promise} which resolves when a response
1051
1053
  * is received or if no response is received after the timeout.
1052
1054
  *
1053
1055
  * @param {string} msg - message to send
@@ -1060,10 +1062,10 @@ class Gateway {
1060
1062
  }
1061
1063
 
1062
1064
  /**
1063
- * Returns a response message received by the gateway. This method returns a {Promise} which resolves when
1065
+ * Returns a response message received by the gateway. This method returns a {Promise} which resolves when
1064
1066
  * a response is received or if no response is received after the timeout.
1065
1067
  *
1066
- * @param {function} [filter=] - original message to which a response is expected, or a MessageClass of the type
1068
+ * @param {function} [filter=] - original message to which a response is expected, or a MessageClass of the type
1067
1069
  * of message to match, or a closure to use to match against the message
1068
1070
  * @param {number} [timeout=0] - timeout in milliseconds
1069
1071
  * @returns {Promise<?Message>} - received response message, null on timeout
@@ -1123,7 +1125,7 @@ const Services = {
1123
1125
  * @param {string} name - fully qualified name of the message class to be created
1124
1126
  * @param {class} [parent=Message] - class of the parent MessageClass to inherit from
1125
1127
  * @returns {function} - constructor for the unqualified message class
1126
- * @example
1128
+ * @example
1127
1129
  * const ParameterReq = MessageClass('org.arl.fjage.param.ParameterReq');
1128
1130
  * let pReq = new ParameterReq()
1129
1131
  */
@@ -1160,7 +1162,7 @@ function _guid(len) {
1160
1162
  s += s4();
1161
1163
  return s;
1162
1164
  }
1163
-
1165
+
1164
1166
  // convert from base 64 to array
1165
1167
  /** @private */
1166
1168
  function _b64toArray(base64, dtype, littleEndian=true) {
@@ -1531,7 +1533,9 @@ class CachingAgentID extends AgentID {
1531
1533
  if (this.greedy && !(Array.isArray(params) && params.includes('name')) && params != 'name') {
1532
1534
  let rsp = await super.get(null, index, timeout);
1533
1535
  this._updateCache(null, rsp, index);
1534
- if (Array.isArray(params)) {
1536
+ if (!rsp) return Array.isArray(params) ? new Array(params.length).fill(null) : null;
1537
+ if (!params) return rsp;
1538
+ else if (Array.isArray(params)) {
1535
1539
  return params.map(p => {
1536
1540
  let f = Object.keys(rsp).find(rv => this._toNamed(rv) === p);
1537
1541
  return f ? rsp[f] : null;
package/dist/unetjs.js CHANGED
@@ -4,30 +4,32 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.unet = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- /* fjage.js v1.9.1-rc6 */
7
+ /* fjage.js v1.10.1 */
8
8
 
9
- /* global window self */
9
+ const isBrowser =
10
+ typeof window !== "undefined" && typeof window.document !== "undefined";
10
11
 
11
- const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
12
+ const isNode =
13
+ typeof process !== "undefined" &&
14
+ process.versions != null &&
15
+ process.versions.node != null;
12
16
 
13
- /* eslint-disable no-restricted-globals */
14
- const isWebWorker = typeof self === 'object'
15
- && self.constructor
16
- && self.constructor.name === 'DedicatedWorkerGlobalScope';
17
- /* eslint-enable no-restricted-globals */
18
-
19
- const isNode = typeof process !== 'undefined'
20
- && process.versions != null
21
- && process.versions.node != null;
17
+ const isWebWorker =
18
+ typeof self === "object" &&
19
+ self.constructor &&
20
+ self.constructor.name === "DedicatedWorkerGlobalScope";
22
21
 
23
22
  /**
24
23
  * @see https://github.com/jsdom/jsdom/releases/tag/12.0.0
25
24
  * @see https://github.com/jsdom/jsdom/issues/1537
26
25
  */
27
- /* eslint-disable no-undef */
28
- const isJsDom = () => (typeof window !== 'undefined' && window.name === 'nodejs')
29
- || navigator.userAgent.includes('Node.js')
30
- || navigator.userAgent.includes('jsdom');
26
+ const isJsDom =
27
+ (typeof window !== "undefined" && window.name === "nodejs") ||
28
+ (typeof navigator !== "undefined" &&
29
+ (navigator.userAgent.includes("Node.js") ||
30
+ navigator.userAgent.includes("jsdom")));
31
+
32
+ typeof Deno !== "undefined" && typeof Deno.core !== "undefined";
31
33
 
32
34
  const SOCKET_OPEN = 'open';
33
35
  const SOCKET_OPENING = 'opening';
@@ -623,9 +625,9 @@
623
625
 
624
626
  /**
625
627
  * A gateway for connecting to a fjage master container. The new version of the constructor
626
- * uses an options object instead of individual parameters. The old version with
627
- *
628
- *
628
+ * uses an options object instead of individual parameters. The old version with
629
+ *
630
+ *
629
631
  * @class
630
632
  * @param {Object} opts
631
633
  * @param {string} [opts.hostname="localhost"] - hostname/ip address of the master container to connect to
@@ -646,7 +648,7 @@
646
648
  if (typeof opts === 'string' || opts instanceof String){
647
649
  opts = {
648
650
  'hostname': opts,
649
- 'port' : port || gObj.location.port,
651
+ 'port' : port || gObj.location.port,
650
652
  'pathname' : pathname,
651
653
  'timeout' : timeout
652
654
  };
@@ -815,7 +817,7 @@
815
817
  return 'inReplyTo' in msg && msg.inReplyTo == filter;
816
818
  } else if (Object.prototype.hasOwnProperty.call(filter, 'msgID')) {
817
819
  return 'inReplyTo' in msg && msg.inReplyTo == filter.msgID;
818
- } else if (filter.__proto__.name == 'Message') {
820
+ } else if (filter.__proto__.name == 'Message' || filter.__proto__.__proto__.name == 'Message') {
819
821
  return filter.__clazz__ == msg.__clazz__;
820
822
  } else if (typeof filter == 'function') {
821
823
  return filter(msg);
@@ -842,13 +844,13 @@
842
844
  if (f.length ) return f[0];
843
845
  return null;
844
846
  }
845
-
847
+
846
848
  /** @private */
847
849
  _addGWCache(gw){
848
850
  if (!gObj.fjage || !gObj.fjage.gateways) return;
849
851
  gObj.fjage.gateways.push(gw);
850
852
  }
851
-
853
+
852
854
  /** @private */
853
855
  _removeGWCache(gw){
854
856
  if (!gObj.fjage || !gObj.fjage.gateways) return;
@@ -1051,7 +1053,7 @@
1051
1053
  }
1052
1054
 
1053
1055
  /**
1054
- * Sends a request and waits for a response. This method returns a {Promise} which resolves when a response
1056
+ * Sends a request and waits for a response. This method returns a {Promise} which resolves when a response
1055
1057
  * is received or if no response is received after the timeout.
1056
1058
  *
1057
1059
  * @param {string} msg - message to send
@@ -1064,10 +1066,10 @@
1064
1066
  }
1065
1067
 
1066
1068
  /**
1067
- * Returns a response message received by the gateway. This method returns a {Promise} which resolves when
1069
+ * Returns a response message received by the gateway. This method returns a {Promise} which resolves when
1068
1070
  * a response is received or if no response is received after the timeout.
1069
1071
  *
1070
- * @param {function} [filter=] - original message to which a response is expected, or a MessageClass of the type
1072
+ * @param {function} [filter=] - original message to which a response is expected, or a MessageClass of the type
1071
1073
  * of message to match, or a closure to use to match against the message
1072
1074
  * @param {number} [timeout=0] - timeout in milliseconds
1073
1075
  * @returns {Promise<?Message>} - received response message, null on timeout
@@ -1127,7 +1129,7 @@
1127
1129
  * @param {string} name - fully qualified name of the message class to be created
1128
1130
  * @param {class} [parent=Message] - class of the parent MessageClass to inherit from
1129
1131
  * @returns {function} - constructor for the unqualified message class
1130
- * @example
1132
+ * @example
1131
1133
  * const ParameterReq = MessageClass('org.arl.fjage.param.ParameterReq');
1132
1134
  * let pReq = new ParameterReq()
1133
1135
  */
@@ -1164,7 +1166,7 @@
1164
1166
  s += s4();
1165
1167
  return s;
1166
1168
  }
1167
-
1169
+
1168
1170
  // convert from base 64 to array
1169
1171
  /** @private */
1170
1172
  function _b64toArray(base64, dtype, littleEndian=true) {
@@ -1535,7 +1537,9 @@
1535
1537
  if (this.greedy && !(Array.isArray(params) && params.includes('name')) && params != 'name') {
1536
1538
  let rsp = await super.get(null, index, timeout);
1537
1539
  this._updateCache(null, rsp, index);
1538
- if (Array.isArray(params)) {
1540
+ if (!rsp) return Array.isArray(params) ? new Array(params.length).fill(null) : null;
1541
+ if (!params) return rsp;
1542
+ else if (Array.isArray(params)) {
1539
1543
  return params.map(p => {
1540
1544
  let f = Object.keys(rsp).find(rv => this._toNamed(rv) === p);
1541
1545
  return f ? rsp[f] : null;