rclnodejs 0.29.0 → 0.31.0

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/README.md CHANGED
@@ -45,7 +45,7 @@ npm i rclnodejs@x.y.z
45
45
 
46
46
  | RCLNODEJS Version | Compatible ROS 2 LTS |
47
47
  | :------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------: |
48
- | latest version (currently [v0.29.0](https://github.com/RobotWebTools/rclnodejs/tree/0.29.0)) | [Humble](https://github.com/RobotWebTools/rclnodejs/tree/humble-hawksbill)<br>[Jazzy](https://github.com/RobotWebTools/rclnodejs/tree/jazzy) |
48
+ | latest version (currently [v0.31.0](https://github.com/RobotWebTools/rclnodejs/tree/0.31.0)) | [Humble](https://github.com/RobotWebTools/rclnodejs/tree/humble-hawksbill)<br>[Jazzy](https://github.com/RobotWebTools/rclnodejs/tree/jazzy) |
49
49
 
50
50
  ## Documentation
51
51
 
package/binding.gyp CHANGED
@@ -10,6 +10,8 @@
10
10
  'variables': {
11
11
  'ros_version': '<!(node scripts/ros_distro.js)',
12
12
  'runtime%': 'node',
13
+ 'ros_lib_dir': "<!(node -p \"require('./scripts/config.js').getROSLibPath()\")",
14
+ 'ros_include_root': "<!(node -p \"require('./scripts/config.js').getROSIncludeRootPath()\")",
13
15
  },
14
16
  'targets': [
15
17
  {
@@ -28,6 +30,7 @@
28
30
  'include_dirs': [
29
31
  '.',
30
32
  "<!(node -e \"require('nan')\")",
33
+ '<(ros_include_root)',
31
34
  ],
32
35
  'cflags!': [
33
36
  '-fno-exceptions'
@@ -61,45 +64,11 @@
61
64
  ],
62
65
  'cflags_cc': [
63
66
  '-std=c++20'
64
- ],
65
- 'include_dirs':
66
- [
67
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/ ') + '/include/')\")",
68
- ],
69
- 'library_dirs': [
70
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/lib/ ') + '/lib/')\")",
71
- ],
72
- 'conditions': [
73
- [
74
- 'ros_version > 2105', # Humble, Rolling, ...
75
- {
76
- 'include_dirs':
77
- [
78
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/ ') + '/include/')\")",
79
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcl/ ') + '/include/rcl')\")",
80
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcutils/ ') + '/include/rcutils/')\")",
81
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rmw/ ') + '/include/rmw/')\")",
82
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcl_yaml_param_parser/ ') + '/include/rcl_yaml_param_parser/')\")",
83
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rosidl_typesupport_interface/ ') + '/include/rosidl_typesupport_interface/')\")",
84
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcl_action/ ') + '/include/rcl_action/')\")",
85
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/action_msgs/ ') + '/include/action_msgs/')\")",
86
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/service_msgs/ ') + '/include/service_msgs/')\")",
87
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/unique_identifier_msgs/ ') + '/include/unique_identifier_msgs/')\")",
88
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/builtin_interfaces/ ') + '/include/builtin_interfaces/')\")",
89
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcl_lifecycle/ ') + '/include/rcl_lifecycle/')\")",
90
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/lifecycle_msgs/ ') + '/include/lifecycle_msgs/')\")",
91
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rosidl_runtime_c/ ') + '/include/rosidl_runtime_c/')\")",
92
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rosidl_dynamic_typesupport/ ') + '/include/rosidl_dynamic_typesupport/')\")",
93
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/type_description_interfaces/ ') + '/include/type_description_interfaces/')\")",
94
- ],
95
- }
96
- ],
97
- ],
67
+ ]
98
68
  }
99
69
  ],
100
70
  [
101
- 'OS=="win"',
102
- {
71
+ 'OS=="win"', {
103
72
  'defines': [
104
73
  'OS_WINDOWS'
105
74
  ],
@@ -108,7 +77,6 @@
108
77
  ],
109
78
  'include_dirs': [
110
79
  './src/third_party/dlfcn-win32/',
111
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include ').replace(/\\\/g, '/') + '/include')\")",
112
80
  ],
113
81
  'msvs_settings': {
114
82
  'VCCLCompilerTool': {
@@ -116,49 +84,17 @@
116
84
  },
117
85
  'VCLinkerTool': {
118
86
  'AdditionalDependencies': ['psapi.lib'],
119
- 'AdditionalLibraryDirectories': ["<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '\\\lib ').replace(/\\\/g, '/') + '/lib')\")",],
87
+ 'AdditionalLibraryDirectories': ['<(ros_lib_dir)'],
120
88
  }
121
- },
122
- 'conditions': [
123
- [
124
- 'ros_version > 2105', # Humble, Rolling, ... TODO - not tested due to broken setup_ros v3.3 action on windows
125
- {
126
- 'include_dirs':
127
- [
128
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rcl ').replace(/\\\/g, '/') + '/include/rcl')\")",
129
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rcutils ').replace(/\\\/g, '/') + '/include/rcutils')\")",
130
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rmw ').replace(/\\\/g, '/') + '/include/rmw')\")",
131
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rcl_yaml_param_parser ').replace(/\\\/g, '/') + '/include/rcl_yaml_param_parser')\")",
132
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rosidl_runtime_c ').replace(/\\\/g, '/') + '/include/rosidl_runtime_c')\")",
133
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rosidl_typesupport_interface ').replace(/\\\/g, '/') + '/include/rosidl_typesupport_interface')\")",
134
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rcl_action ').replace(/\\\/g, '/') + '/include/rcl_action')\")",
135
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/action_msgs ').replace(/\\\/g, '/') + '/include/action_msgs')\")",
136
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/service_msgs ').replace(/\\\/g, '/') + '/include/service_msgs')\")",
137
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/unique_identifier_msgs ').replace(/\\\/g, '/') + '/include/unique_identifier_msgs')\")",
138
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/builtin_interfaces ').replace(/\\\/g, '/') + '/include/builtin_interfaces')\")",
139
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rcl_lifecycle ').replace(/\\\/g, '/') + '/include/rcl_lifecycle')\")",
140
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/lifecycle_msgs ').replace(/\\\/g, '/') + '/include/lifecycle_msgs')\")",
141
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rosidl_dynamic_typesupport ').replace(/\\\/g, '/') + '/include/rosidl_dynamic_typesupport')\")",
142
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/type_description_interfaces/ ').replace(/\\\/g, '/') + '/include/type_description_interfaces/')\")",
143
- ],
144
- }
145
- ]
146
- ]
89
+ }
147
90
  }
148
91
  ],
149
92
  [
150
- 'OS=="mac"',
151
93
  # TODO - macos is no longer a tier-1 ROS platform and we have no binary ROS builds to test for Humble & Rolling
152
- {
94
+ 'OS=="mac"', {
153
95
  'defines': [
154
96
  'OS_MACOS'
155
97
  ],
156
- 'include_dirs': [
157
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/ ') + '/include/')\")",
158
- ],
159
- 'library_dirs': [
160
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/lib/ ') + '/lib/')\")",
161
- ],
162
98
  'xcode_settings': {
163
99
  'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
164
100
  'CLANG_CXX_LIBRARY': 'libc++',
@@ -168,8 +104,7 @@
168
104
  }
169
105
  ],
170
106
  [
171
- 'ros_version<=1911',
172
- {
107
+ 'ros_version <= 1911', {
173
108
  'libraries': [
174
109
  '-lrosidl_generator_c'
175
110
  ],
@@ -178,9 +113,22 @@
178
113
  ]
179
114
  }
180
115
  ],
181
- ['runtime=="electron"', {
182
- "defines": ["NODE_RUNTIME_ELECTRON=1"]
183
- }],
116
+ [
117
+ # After Galactic, e.g., Humble, Jazzy, Rolling.
118
+ 'ros_version > 2105', {
119
+ 'include_dirs': [
120
+ "<!@(node -p \"require('./scripts/config.js').getIncludePaths().forEach(p => console.log(JSON.stringify(p)))\")"
121
+ ],
122
+ 'library_dirs': [
123
+ '<(ros_lib_dir)',
124
+ ]
125
+ }
126
+ ],
127
+ [
128
+ 'runtime=="electron"', {
129
+ "defines": ["NODE_RUNTIME_ELECTRON=1"]
130
+ }
131
+ ],
184
132
  ]
185
133
  }
186
134
  ]
@@ -266,10 +266,12 @@ class ActionServer extends Entity {
266
266
  let goalHandle;
267
267
  if (accepted) {
268
268
  // Stamp time of acceptance
269
- const secondsAndNanos = this._node.getClock().now().secondsAndNanoseconds;
269
+ const { seconds, nanoseconds } = this._node
270
+ .getClock()
271
+ .now().secondsAndNanoseconds;
270
272
  goalInfo.stamp = {
271
- sec: secondsAndNanos.seconds,
272
- nanosec: secondsAndNanos.nanoseconds,
273
+ sec: Number(seconds),
274
+ nanosec: Number(nanoseconds),
273
275
  };
274
276
 
275
277
  try {
package/lib/clock.js CHANGED
@@ -52,8 +52,8 @@ class Clock {
52
52
  * @return {Time} Return the current time.
53
53
  */
54
54
  now() {
55
- let time = rclnodejs.clockGetNow(this._handle);
56
- return new Time(time.sec, time.nanosec, this._clockType);
55
+ const nowInNanosec = rclnodejs.clockGetNow(this._handle);
56
+ return new Time(0n, nowInNanosec, this._clockType);
57
57
  }
58
58
  }
59
59
 
package/lib/duration.js CHANGED
@@ -15,7 +15,7 @@
15
15
  'use strict';
16
16
 
17
17
  const rclnodejs = require('bindings')('rclnodejs');
18
- const int64 = require('int64-napi');
18
+ const S_TO_NS = 10n ** 9n;
19
19
 
20
20
  /**
21
21
  * @class - Class representing a Duration in ROS
@@ -24,51 +24,38 @@ const int64 = require('int64-napi');
24
24
  class Duration {
25
25
  /**
26
26
  * Create a Duration.
27
- * @param {number|string} [seconds=0] - The second part of the duration.
28
- * @param {number|string} [nanoseconds=0] - The nanosecond part of the duration.
27
+ * @param {bigint} [seconds=0] - The second part of the duration.
28
+ * @param {bigint} [nanoseconds=0] - The nanosecond part of the duration.
29
29
  */
30
- constructor(seconds = 0, nanoseconds = 0) {
31
- if (typeof seconds !== 'number' && typeof seconds !== 'string') {
30
+ constructor(seconds = 0n, nanoseconds = 0n) {
31
+ if (typeof seconds !== 'bigint') {
32
32
  throw new TypeError('Invalid argument of seconds');
33
33
  }
34
34
 
35
- if (typeof nanoseconds !== 'number' && typeof nanoseconds !== 'string') {
35
+ if (typeof nanoseconds !== 'bigint') {
36
36
  throw new TypeError('Invalid argument of nanoseconds');
37
37
  }
38
38
 
39
- let secondInt64 = int64.from(seconds);
40
- let nanoInt64 = int64.from(nanoseconds);
41
-
42
- if (typeof seconds === 'string' && seconds.startsWith('-')) {
43
- secondInt64 = int64.negative(secondInt64);
44
- }
45
- if (typeof nanoseconds === 'string' && nanoseconds.startsWith('-')) {
46
- nanoInt64 = int64.negative(nanoInt64);
39
+ const total = seconds * S_TO_NS + nanoseconds;
40
+ if (total >= 2n ** 63n) {
41
+ throw new RangeError(
42
+ 'Total nanoseconds value is too large to store in C time point.'
43
+ );
47
44
  }
48
- this._nanoseconds = secondInt64.multiply(1e9).add(nanoInt64);
49
- this._handle = rclnodejs.createDuration(this._nanoseconds.toString());
45
+
46
+ this._nanoseconds = total;
47
+ this._handle = rclnodejs.createDuration(this._nanoseconds);
50
48
  }
51
49
 
52
50
  /**
53
51
  * Get the nanosecond part of the Duration.
54
52
  * @name Duration#get:nanoseconds
55
53
  * @function
56
- * @return {number|string} - value in nanosecond, if the value is greater than Number.MAX_SAFE_INTEGER (2^53-1), will be presented in string of decimal format.
54
+ * @return {bigint} - value in nanosecond.
57
55
  */
58
56
 
59
57
  get nanoseconds() {
60
- let nanoStr = rclnodejs.getDurationNanoseconds(this._handle);
61
- let nano;
62
-
63
- if (nanoStr.startsWith('-')) {
64
- nano = int64.negative(int64.from(nanoStr));
65
- } else {
66
- nano = int64.from(nanoStr);
67
- }
68
- if (Number.isFinite(nano.toNumber())) {
69
- return nano.toNumber();
70
- }
71
- return nano.toString();
58
+ return rclnodejs.getDurationNanoseconds(this._handle);
72
59
  }
73
60
 
74
61
  /**
@@ -78,7 +65,7 @@ class Duration {
78
65
  */
79
66
  eq(other) {
80
67
  if (other instanceof Duration) {
81
- return this._nanoseconds.eq(other.nanoseconds);
68
+ return this._nanoseconds === other.nanoseconds;
82
69
  }
83
70
  throw new TypeError(
84
71
  `Can't compare duration with object of type: ${other.constructor.name}`
@@ -92,7 +79,7 @@ class Duration {
92
79
  */
93
80
  ne(other) {
94
81
  if (other instanceof Duration) {
95
- return this._nanoseconds.ne(other.nanoseconds);
82
+ return this._nanoseconds !== other.nanoseconds;
96
83
  }
97
84
  throw new TypeError('Invalid argument');
98
85
  }
@@ -104,7 +91,7 @@ class Duration {
104
91
  */
105
92
  lt(other) {
106
93
  if (other instanceof Duration) {
107
- return this._nanoseconds.lt(other.nanoseconds);
94
+ return this._nanoseconds < other.nanoseconds;
108
95
  }
109
96
  throw new TypeError('Invalid argument');
110
97
  }
@@ -116,7 +103,7 @@ class Duration {
116
103
  */
117
104
  lte(other) {
118
105
  if (other instanceof Duration) {
119
- return this._nanoseconds.lte(other.nanoseconds);
106
+ return this._nanoseconds <= other.nanoseconds;
120
107
  }
121
108
  throw new TypeError('Invalid argument');
122
109
  }
@@ -128,7 +115,7 @@ class Duration {
128
115
  */
129
116
  gt(other) {
130
117
  if (other instanceof Duration) {
131
- return this._nanoseconds.gt(other.nanoseconds);
118
+ return this._nanoseconds > other.nanoseconds;
132
119
  }
133
120
  throw new TypeError('Invalid argument');
134
121
  }
@@ -140,7 +127,7 @@ class Duration {
140
127
  */
141
128
  gte(other) {
142
129
  if (other instanceof Duration) {
143
- return this._nanoseconds.gte(other.nanoseconds);
130
+ return this._nanoseconds >= other.nanoseconds;
144
131
  }
145
132
  throw new TypeError('Invalid argument');
146
133
  }
package/lib/node.js CHANGED
@@ -507,7 +507,7 @@ class Node extends rclnodejs.ShadowNode {
507
507
 
508
508
  /**
509
509
  * Create a Timer.
510
- * @param {number} period - The number representing period in millisecond.
510
+ * @param {bigint} period - The number representing period in nanoseconds.
511
511
  * @param {function} callback - The callback to be called when timeout.
512
512
  * @param {Clock} [clock] - The clock which the timer gets time from.
513
513
  * @return {Timer} - An instance of Timer.
@@ -519,22 +519,11 @@ class Node extends rclnodejs.ShadowNode {
519
519
  clock = arguments[3];
520
520
  }
521
521
 
522
- if (typeof period !== 'number' || typeof callback !== 'function') {
522
+ if (typeof period !== 'bigint' || typeof callback !== 'function') {
523
523
  throw new TypeError('Invalid argument');
524
524
  }
525
525
 
526
- // The period unit is millisecond in JavaScript side. When being passed to the
527
- // C++ side, the value will be converted to nanosecond, which goes into a uint64_t
528
- // with maxmium value of 2^64-1. So the maxmium is UINT64_MAX in ns, that's 0x10c6f7a0b5ed in ms.
529
- const MAX_TIMER_PERIOD_IN_MILLISECOND = 0x10c6f7a0b5ed;
530
- if (period > 0x10c6f7a0b5ed || period < 0) {
531
- throw new RangeError(
532
- `Parameter must be between 0.0 and ${MAX_TIMER_PERIOD_IN_MILLISECOND}`
533
- );
534
- }
535
-
536
526
  const timerClock = clock || this._clock;
537
-
538
527
  let timerHandle = rclnodejs.createTimer(
539
528
  timerClock.handle,
540
529
  this.context.handle,
@@ -573,7 +562,7 @@ class Node extends rclnodejs.ShadowNode {
573
562
  }
574
563
 
575
564
  const period = Math.round(1000 / hz);
576
- const timer = this._rateTimerServer.createTimer(period);
565
+ const timer = this._rateTimerServer.createTimer(BigInt(period) * 1000000n);
577
566
  const rate = new Rates.Rate(hz, timer);
578
567
 
579
568
  return rate;
@@ -1480,10 +1469,10 @@ class Node extends rclnodejs.ShadowNode {
1480
1469
  PARAMETER_EVENT_MSG_TYPE
1481
1470
  ))();
1482
1471
 
1483
- const secondsAndNanos = this._clock.now().secondsAndNanoseconds;
1472
+ const { seconds, nanoseconds } = this._clock.now().secondsAndNanoseconds;
1484
1473
  parameterEvent.stamp = {
1485
- sec: secondsAndNanos.seconds,
1486
- nanosec: secondsAndNanos.nanoseconds,
1474
+ sec: Number(seconds),
1475
+ nanosec: Number(nanoseconds),
1487
1476
  };
1488
1477
 
1489
1478
  parameterEvent.node =
package/lib/parameter.js CHANGED
@@ -34,6 +34,7 @@ const rclnodejs = require('bindings')('rclnodejs');
34
34
  const DEFAULT_NUMERIC_RANGE_TOLERANCE = 1e-6;
35
35
 
36
36
  const PARAMETER_SEPARATOR = '.';
37
+ const PARAMETER_BYTE = 10;
37
38
 
38
39
  /**
39
40
  * Enum for ParameterType
@@ -125,7 +126,9 @@ class Parameter {
125
126
  constructor(name, type, value) {
126
127
  this._name = name;
127
128
  this._type = type;
128
- this._value = value;
129
+ // Convert to bigint if it's type of `PARAMETER_INTEGER`.
130
+ this._value =
131
+ this._type == ParameterType.PARAMETER_INTEGER ? BigInt(value) : value;
129
132
  this._isDirty = true;
130
133
 
131
134
  this.validate();
@@ -240,10 +243,10 @@ class Parameter {
240
243
  msg.double_array_value = this.value;
241
244
  break;
242
245
  case ParameterType.PARAMETER_INTEGER:
243
- msg.integer_value = Math.trunc(this.value);
246
+ msg.integer_value = this.value;
244
247
  break;
245
248
  case ParameterType.PARAMETER_INTEGER_ARRAY:
246
- msg.integer_array_value = this.value.map((val) => Math.trunc(val));
249
+ msg.integer_array_value = this.value;
247
250
  break;
248
251
  case ParameterType.PARAMETER_STRING:
249
252
  msg.string_value = this.value;
@@ -537,10 +540,10 @@ class Range {
537
540
 
538
541
  /**
539
542
  * Determine if a value is within this range.
540
- * A TypeError is thrown when value is not a number.
543
+ * A TypeError is thrown when value is not a number or bigint.
541
544
  * Subclasses should override and call this method for basic type checking.
542
545
  *
543
- * @param {number} value - The number to check.
546
+ * @param {number|bigint} value - The number or bigint to check.
544
547
  * @return {boolean} - True if value satisfies the range; false otherwise.
545
548
  */
546
549
  inRange(value) {
@@ -550,8 +553,8 @@ class Range {
550
553
  (inRange, val) => inRange && this.inRange(val),
551
554
  true
552
555
  );
553
- } else if (typeof value !== 'number') {
554
- throw new TypeError('Value must be a number');
556
+ } else if (typeof value !== 'number' && typeof value !== 'bigint') {
557
+ throw new TypeError('Value must be a number or bigint');
555
558
  }
556
559
 
557
560
  return true;
@@ -652,27 +655,16 @@ class FloatingPointRange extends Range {
652
655
  * Defines a range for integer values.
653
656
  * @class
654
657
  */
655
- class IntegerRange extends FloatingPointRange {
658
+ class IntegerRange extends Range {
656
659
  /**
657
660
  * Create a new instance.
658
661
  * @constructor
659
- * @param {number} fromValue - The lowest inclusive value in range
660
- * @param {number} toValue - The highest inclusive value in range
661
- * @param {number} step - The internal unit size.
662
- * @param {number} tolerance - The plus/minus tolerance for number equivalence.
662
+ * @param {bigint} fromValue - The lowest inclusive value in range
663
+ * @param {bigint} toValue - The highest inclusive value in range
664
+ * @param {bigint} step - The internal unit size.
663
665
  */
664
- constructor(
665
- fromValue,
666
- toValue,
667
- step = 1,
668
- tolerance = DEFAULT_NUMERIC_RANGE_TOLERANCE
669
- ) {
670
- super(
671
- Math.trunc(fromValue),
672
- Math.trunc(toValue),
673
- Math.trunc(step),
674
- tolerance
675
- );
666
+ constructor(fromValue, toValue, step = 1n) {
667
+ super(fromValue, toValue, step);
676
668
  }
677
669
 
678
670
  /**
@@ -683,12 +675,23 @@ class IntegerRange extends FloatingPointRange {
683
675
  */
684
676
  isValidType(parameterType) {
685
677
  const result =
686
- parameterType === ParameterType.PARAMETER_BYTE ||
687
- parameterType === ParameterType.PARAMETER_BYTE_ARRAY ||
688
678
  parameterType === ParameterType.PARAMETER_INTEGER ||
689
679
  parameterType === ParameterType.PARAMETER_INTEGER_ARRAY;
690
680
  return result;
691
681
  }
682
+
683
+ inRange(value) {
684
+ const min = this.fromValue;
685
+ const max = this.toValue;
686
+ if (value < min || value > max) {
687
+ return false;
688
+ }
689
+
690
+ if (this.step != 0n && (value - min) % this.step !== 0n) {
691
+ return false;
692
+ }
693
+ return true;
694
+ }
692
695
  }
693
696
 
694
697
  /**
@@ -763,10 +766,13 @@ function validValue(value, type) {
763
766
  case ParameterType.PARAMETER_STRING:
764
767
  result = typeof value === 'string';
765
768
  break;
766
- case ParameterType.PARAMETER_INTEGER:
767
769
  case ParameterType.PARAMETER_DOUBLE:
770
+ case PARAMETER_BYTE:
768
771
  result = typeof value === 'number';
769
772
  break;
773
+ case ParameterType.PARAMETER_INTEGER:
774
+ result = typeof value === 'bigint';
775
+ break;
770
776
  case ParameterType.PARAMETER_BOOL_ARRAY:
771
777
  case ParameterType.PARAMETER_BYTE_ARRAY:
772
778
  case ParameterType.PARAMETER_INTEGER_ARRAY:
@@ -789,7 +795,7 @@ function _validArray(values, type) {
789
795
  if (type === ParameterType.PARAMETER_BOOL_ARRAY) {
790
796
  arrayElementType = ParameterType.PARAMETER_BOOL;
791
797
  } else if (type === ParameterType.PARAMETER_BYTE_ARRAY) {
792
- arrayElementType = ParameterType.PARAMETER_INTEGER;
798
+ arrayElementType = PARAMETER_BYTE;
793
799
  }
794
800
  if (type === ParameterType.PARAMETER_INTEGER_ARRAY) {
795
801
  arrayElementType = ParameterType.PARAMETER_INTEGER;
package/lib/rate.js CHANGED
@@ -166,7 +166,7 @@ class RateTimerServer {
166
166
  /**
167
167
  * Create a new timer instance with callback set to NOP.
168
168
  *
169
- * @param {number} period - The period in milliseconds
169
+ * @param {bigint} period - The period in nanoseconds.
170
170
  * @returns {Timer} - The new timer instance.
171
171
  */
172
172
  createTimer(period) {