8000 Fix Map#concat · philipp-spiess/immutable-js@d785d58 · GitHub
[go: up one dir, main page]

Skip to content

Commit d785d58

Browse files
Fix Map#concat
immutable-js#1373 made `Map#concat` an alias for `Map#merge` but defined the alias before `Map#merge` was defined, resulting in `Map#concat` being undefined. This fixes the issue and adds a regression test.
1 parent 82d05a2 commit d785d58

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

__tests__/Map.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ describe('Map', () => {
129129
expect(m3.toObject()).toEqual({a: 'A', b: 'BB', c: 'C', wow: 'OO', d: 'DD'});
130130
});
131131

132+
it('concatenates two maps (alias for merge)', () => {
133+
const m1 = Map({ a: 'A', b: 'B', c: 'C' });
134+
const m2 = Map({ wow: 'OO', d: 'DD', b: 'BB' });
135+
expect(m2.toObject()).toEqual({ wow: 'OO', d: 'DD', b: 'BB' });
136+
const m3 = m1.concat(m2);
137+
expect(m3.toObject()).toEqual({a: 'A', b: 'BB', c: 'C', wow: 'OO', d: 'DD'});
138+
});
139+
132140
it('accepts null as a key', () => {
133141
const m1 = Map<any, any>();
134142
const m2 = m1.set(null, 'null');

src/Map.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export const MapPrototype = Map.prototype;
170170
MapPrototype[IS_MAP_SENTINEL] = true;
171171
MapPrototype[DELETE] = MapPrototype.remove;
172172
MapPrototype.removeAll = MapPrototype.deleteAll;
173-
MapPrototype.concat = MapPrototype.merge;
173+
MapPrototype.concat = merge;
174174
MapPrototype.setIn = setIn;
175175
MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn;
176176
MapPrototype.update = update;

0 commit comments

Comments
 (0)
0