Skip to content

Undocumented breaking change in v4: equal Node buffers no longer considered equal #1437

Closed
@callumlocke

Description

@callumlocke

What happened

Until v3, Immutable.is treated two collections containing equivalent Node Buffers as equal, because Node buffers happen to have an .equals() method similar to an Immutable collection.

In v4, this is no longer the case.

How to reproduce

Try the following with Immutable v3 and v4:

import { is, Map } from 'immutable'

const a = Map({
  'foo.txt': Buffer.from('hello')
})

const b = Map({
  'foo.txt': Buffer.from('hello')
})

is(a, b) // true in v3, but false in v4

Summary

This change may be a good thing, as the old behaviour always felt a little magical. And I'm not sure if it was ever officially documented. But @leebyron once told me (in #720) that the old behaviour was desirable, even if accidental. So if this change is intentional, I think it should be flagged up in the release notes as a breaking change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions