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

RobotWebTools / rclnodejs / #958

06 Mar 2025 04:45AM UTC coverage: 85.075% (-5.4%) from 90.471%
#958

push

web-flow
Update .npmignore (#1062)

This patch updates `.npmignore` to exclude files not needed in the npm package.

Fix: #1061

706 of 920 branches covered (76.74%)

Branch coverage included in aggregate %.

1728 of 1941 relevant lines covered (89.03%)

343.48 hits per line

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

90.48
/lib/entity.js
1
// Copyright (c) 2017 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
// Destroying an entity for which there is immediate i/o activity can
18
// results in a SEGFAULT. To mitigate this situation we hold a
19
// reference to released handles to prevent them from being
20
// GC'ed prematurely.
21
const OBSOLETE_HANDLES = new Set();
26✔
22
function registerObsoleteHandle(handle) {
23
  OBSOLETE_HANDLES.add(handle);
100✔
24
}
25

26
/**
27
 * @class - Class representing a common object in RCL.
28
 * @ignore
29
 */
30

31
class Entity {
32
  /**
33
   * Clears the internal short-lived cache of references to
34
   * destroyed entities.
35
   *
36
   * @ignore
37
   */
38
  static _gcHandles() {
39
    OBSOLETE_HANDLES.clear();
4,543✔
40
  }
41

42
  constructor(handle, typeClass, options) {
43
    this._handle = handle;
4,720✔
44
    this._typeClass = typeClass;
4,720✔
45
    this._options = options;
4,720✔
46
    this._destroyed = false;
4,720✔
47
  }
48

49
  get handle() {
50
    return this._handle;
7,037✔
51
  }
52

53
  get options() {
54
    return this._options;
41✔
55
  }
56

57
  set options(options) {
58
    this._options = options;
×
59
  }
60

61
  get qos() {
62
    return this._options.qos;
392✔
63
  }
64

65
  get typedArrayEnabled() {
66
    return this._options.enableTypedArray;
470✔
67
  }
68

69
  get typeClass() {
70
    return this._typeClass;
901✔
71
  }
72

73
  /**
74
   * Release all resources held by this entity.
75
   * Do not call this method directly.
76
   */
77
  _destroy() {
78
    if (this.isDestroyed()) return;
100!
79

80
    this._destroyed = true;
100✔
81
    this.handle.release();
100✔
82
    registerObsoleteHandle(this._handle);
100✔
83
  }
84

85
  /**
86
   * Test if this entity has been destroyed and resources released.
87
   * @returns {boolean} - true when destroyed has previously been called.
88
   */
89
  isDestroyed() {
90
    return this._destroyed;
1,009✔
91
  }
92
}
93

94
module.exports = Entity;
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