Skip to content

Node buffers have an .equals() method too #720

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

Closed
callumlocke opened this issue Dec 17, 2015 · 3 comments
Closed

Node buffers have an .equals() method too #720

callumlocke opened this issue Dec 17, 2015 · 3 comments

Comments

@callumlocke
Copy link

Is this considered a problem for Immutable's is algrorithm?

var Immutable = require('immutable');

var map1 = Immutable.Map({
  foo: new Buffer('hi'),
});

var map2 = Immutable.Map({
  foo: new Buffer('hi'),
});

Immutable.is(map1, map2); // true

map1.get('foo').x = 123;

Immutable.is(map1, map2); // true
map1.get('foo').x; // 123
map2.get('foo').x; // undefined

(Try above snippet on Tonic)

see Node Buffer#equals()

@leebyron
Copy link
Collaborator

Actually this is kind of awesome, I'm not sure I would consider this problematic but an (accidental) usage of Immutable.js's value protocol by node Buffer.

I suppose this is a problem for Immutable.js as much as the following is a problem for Node:

var buf1 = new Buffer('hi');
var buf2 = new Buffer('hi');
buf1.x = 123;
buf1.equals(buf2); // true

I'm curious what your expectations here. Should we not treat buffers as values? Does this cause a real issue for you, or is this only a theoretical concern?

@callumlocke
Copy link
Author

It's just a theoretical concern yeah. I can see it might be a happy accident...

@leebyron
Copy link
Collaborator

leebyron commented Mar 8, 2017

Closing this aging issue

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