Immutable.Map.deleteAll () is not a function

Consider the following code:

const person = Immutable.Map({
    name: 'John',
    surname: 'Maverick',
    age: 39
});

const mutated = person.deleteAll(['name', 'age']);

Expected Result: mutatednow represents a new instance of the card with the removed keys nameand age. However, it throws an exception:

Uncaught TypeError: person.deleteAll is not a function

When testing available prototype methods, Immutable.Mapthere are no deleteAlland methods removeAll. Are they deleted?

The method is specified in the official documentation of ImmutableJS, but it is not available. What will be an integral alternative in this case? Thank.

+4
source share
3 answers

, (ver. 4 RC1 & RC2). src, 3.8.1. 4.0.0-rc.2, .

+4

, deleteAll . ...

const mutated = ['name', 'age'].reduce((map, key) => map.delete(key), person);
+2

, deleteIn?

https://facebook.imtqy.com/immutable-js/docs/#/Map/deleteIn

person.deleteIn(['name', 'age']);
-1

Source: https://habr.com/ru/post/1673098/


All Articles