question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use number as node name

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
albertorestifocommented, Feb 24, 2017

@kronick Good point.

That’s can be the sweet spot. Have the ability to pass Map to all the methods.

1reaction
kronickcommented, Feb 22, 2017

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found