Can't use number as node name
See original GitHub issueI did the following in my code and expected to get a path [1, 2]
. But it returned null.
route.addNode(1, { 2: 10, 3: 20 });
console.log(route.path(1, 2));
Turned out it doesn’t like me using numbers as the name of a node. It would be good if the library checks and raises an error, or make it work.
it('adds a node 2', () => {
const route = new Graph();
route.addNode(1, { 2: 10, 3: 20 });
const node = route.graph.get(1);
demand(node).be.instanceOf(Map);
demand(node.get('2')).equal(10); //<--- this is fine
demand(node.get(3)).equal(20); // <--- this fails
});
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
can we use a number as text node in XML file? - Stack Overflow
Any name can be used, no words are reserved. according to 2nd rule you cant use a number as text node in XML...
Read more >An assign statement is throwing an error when node name ...
A node name CANNOT start with a NUMBER. It is invalid according to the XML specification. The node name can be changed as...
Read more >Specify the Node Naming Series - Microsoft Learn
The naming series is defined by selecting a root name and the starting number that will accompany that name. The starting number is...
Read more >How To Use a ROS Anonymous Node - The Robotics Back-End
Knowing that a node should have a unique name, and that you can't run 2 nodes with the same name, what can you...
Read more >Automatic Node Name Generation - Innovyze
nn is either a pair of numbers, a pair of letters , or a combination of a number and a letter, which are...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@kronick Good point.
That’s can be the sweet spot. Have the ability to pass
Map
to all the methods.I ran into the same issue and came here to report it. This is a great library and clearing up this ambiguity would make it even better!
My nodes don’t have natural names so using numbers for the keys makes the most sense. Why not use a ES6
Map
throughout and allow arbitrary types for all keys?