Skip to content

Commit ee520b0

Browse files
committed
refactor(UrdfLink): Convert UrdfLink to TypeScript, loop with for-of since ES6 provides it
Signed-off-by: Drew Hoener <[email protected]>
1 parent 5410af3 commit ee520b0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/urdf/UrdfLink.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
*/
66

77
import UrdfVisual from './UrdfVisual.js';
8+
import { UrdfAttrs, type UrdfDefaultOptions } from './UrdfTypes.js';
89

910
/**
1011
* A Link element in a URDF.
1112
*/
1213
export default class UrdfLink {
13-
/**
14-
* @param {Object} options
15-
* @param {Element} options.xml - The XML element to parse.
16-
*/
17-
constructor(options) {
18-
this.name = options.xml.getAttribute('name');
19-
this.visuals = [];
20-
var visuals = options.xml.getElementsByTagName('visual');
2114

22-
for (var i = 0; i < visuals.length; i++) {
15+
name: string;
16+
visuals: UrdfVisual[] = [];
17+
18+
constructor({ xml }: UrdfDefaultOptions) {
19+
this.name = xml.getAttribute(UrdfAttrs.Name) ?? 'unknown_name';
20+
const visuals = xml.getElementsByTagName(UrdfAttrs.Visuals);
21+
22+
for (const visual of visuals) {
2323
this.visuals.push(
2424
new UrdfVisual({
25-
xml: visuals[i]
25+
xml: visual
2626
})
2727
);
2828
}

0 commit comments

Comments
 (0)