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

RobotWebTools / rclnodejs / 15752436712

19 Jun 2025 07:44AM UTC coverage: 84.672% (-0.06%) from 84.731%
15752436712

Pull #1173

github

web-flow
Merge 6b96e9c99 into 688791eae
Pull Request #1173: Add RMW serialize and deserialize functions

770 of 999 branches covered (77.08%)

Branch coverage included in aggregate %.

9 of 11 new or added lines in 2 files covered. (81.82%)

1898 of 2152 relevant lines covered (88.2%)

3199.38 hits per line

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

71.43
/lib/serialization.js
1
// Copyright (c) 2025, The Robot Web Tools Contributors
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('bindings')('rclnodejs');
208✔
18

19
class Serialization {
20
  static serializeMessage(message, typeClass) {
21
    if (!(message instanceof typeClass)) {
24!
NEW
22
      throw new TypeError('Message must be a valid ros2 message type');
×
23
    }
24
    return rclnodejs.serialize(
24✔
25
      typeClass.type().pkgName,
26
      typeClass.type().subFolder,
27
      typeClass.type().interfaceName,
28
      message.serialize()
29
    );
30
  }
31

32
  static deserializeMessage(buffer, typeClass) {
33
    if (!(buffer instanceof Buffer)) {
24!
NEW
34
      throw new TypeError('Buffer is required for deserialization');
×
35
    }
36
    const rosMsg = new typeClass();
24✔
37
    rclnodejs.deserialize(
24✔
38
      typeClass.type().pkgName,
39
      typeClass.type().subFolder,
40
      typeClass.type().interfaceName,
41
      buffer,
42
      rosMsg.toRawROS()
43
    );
44
    return rosMsg;
24✔
45
  }
46
}
47

48
module.exports = Serialization;
208✔
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