Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set behavior vary from Browser vs Node? #249

Open
JSeligstein opened this issue Dec 13, 2022 · 6 comments
Open

Set behavior vary from Browser vs Node? #249

JSeligstein opened this issue Dec 13, 2022 · 6 comments

Comments

@JSeligstein
Copy link

The following code appears to work as expected (true) in browser, but fails in a brand-new clean node project. Am I missing something?

const Set = require('collections/set');
const myset = new Set(null, function(a, b) {
return a.x == b.x && a.y == b.y;
}, function(object) {
return ''+object.x+'.'+object.y;
});

myset.add({x:0, y:0});
console.log(myset.has({x: 0, y:0}));

@hthetiot
Copy link
Contributor

Please provide nodejs version.

@JSeligstein
Copy link
Author

I literally ran:

node init
node install --save collections

Then ran the above file.

@hthetiot
Copy link
Contributor

hthetiot commented Dec 13, 2022

@JSeligstein that not what I asked you.
Please provide NodeJs and Npm version aka node --version and npm --version commands results...

@hthetiot

This comment was marked as resolved.

@hthetiot hthetiot changed the title Browser vs Node? Set behavior vary from Browser vs Node? Dec 13, 2022
@JSeligstein
Copy link
Author

For some reason, in the past I feel like if you did int + string + int it would try to cast everything to Number instead of strings. The old-school trick was to use a string first. '' + x + '.' + y is perfectly valid, though perhaps unnecessary it may seem. Feel free to remove the single-quotes there.

% node --version
v19.0.1
% npm --version
8.19.2

I'm sorry about the original answer. I thought you meant version of code. I'm tired today.

@hthetiot
Copy link
Contributor

Thank you, the nodejs version is usefull.
I may assist with some issue here as co-maintainer.

No promise but I will look into giving some love to this project this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants