• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

RobotWebTools / rclnodejs / 19071410104

04 Nov 2025 02:08PM UTC coverage: 83.072% (+0.4%) from 82.711%
19071410104

Pull #1320

github

web-flow
Merge 9cad4567e into 3ad842cc4
Pull Request #1320: feat: add structured error handling with class error hierarchy

1032 of 1365 branches covered (75.6%)

Branch coverage included in aggregate %.

161 of 239 new or added lines in 25 files covered. (67.36%)

29 existing lines in 1 file now uncovered.

2354 of 2711 relevant lines covered (86.83%)

459.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.48
/lib/clock.js
1
// Copyright (c) 2018 Intel Corporation. All rights reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
'use strict';
16

17
const rclnodejs = require('./native_loader.js');
26✔
18
const Time = require('./time.js');
26✔
19
const ClockType = require('./clock_type.js');
26✔
20
const { TypeValidationError } = require('./errors.js');
26✔
21

22
/**
23
 * @class - Class representing a Clock in ROS
24
 */
25

26
class Clock {
27
  /**
28
   * Create a Clock.
29
   * @param {ClockType} [clockType=Clock.ClockType.SYSTEM_TIME] - The type of the clock to be created.
30
   */
31
  constructor(clockType = ClockType.SYSTEM_TIME) {
1✔
32
    this._clockType = clockType;
698✔
33
    this._handle = rclnodejs.createClock(this._clockType);
698✔
34
  }
35

36
  /**
37
   * @ignore
38
   */
39
  get handle() {
40
    return this._handle;
109✔
41
  }
42

43
  /**
44
   * Get ClockType of this Clock object.
45
   * @return {ClockType} Return the type of the clock.
46
   */
47
  get clockType() {
48
    return this._clockType;
4✔
49
  }
50

51
  /**
52
   * Return the current time.
53
   * @return {Time} Return the current time.
54
   */
55
  now() {
56
    const nowInNanosec = rclnodejs.clockGetNow(this._handle);
1,896✔
57
    return new Time(0n, nowInNanosec, this._clockType);
1,896✔
58
  }
59
}
60

61
/**
62
 * @class - Class representing a ROSClock in ROS
63
 */
64

65
class ROSClock extends Clock {
66
  /**
67
   * Create a ROSClock.
68
   */
69
  constructor() {
70
    super(ClockType.ROS_TIME);
695✔
71
  }
72

73
  /**
74
   * Return status that whether the ROS time is active.
75
   * @name ROSClock#get:isRosTimeActive
76
   * @function
77
   * @return {boolean} Return true if the time is active, otherwise return false.
78
   */
79

80
  get isRosTimeActive() {
81
    return rclnodejs.getRosTimeOverrideIsEnabled(this._handle);
3✔
82
  }
83

84
  /**
85
   * Set the status of ROS time.
86
   * @param {boolean} enabled - Set the ROS time to be active.
87
   * @name ROSClock#set:isRosTimeActive
88
   * @function
89
   * @return {undefined}
90
   */
91

92
  set isRosTimeActive(enabled) {
93
    rclnodejs.setRosTimeOverrideIsEnabled(this._handle, enabled);
696✔
94
  }
95

96
  /**
97
   * Set the status of ROS time.
98
   * @param {Time} time - The time to be set override.
99
   * @name ROSClock#set:rosTimeOverride
100
   * @function
101
   * @return {undefined}
102
   */
103

104
  set rosTimeOverride(time) {
105
    if (!(time instanceof Time)) {
699!
NEW
106
      throw new TypeValidationError('time', time, 'Time', {
×
107
        entityType: 'clock',
108
      });
109
    }
110
    rclnodejs.setRosTimeOverride(this._handle, time._handle);
699✔
111
  }
112
}
113

114
Clock.ClockType = ClockType;
26✔
115

116
module.exports = { Clock, ROSClock };
26✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc