September 2017
Intermediate to advanced
216 pages
6h 8m
English
This brings us to our ultimate lazy pattern. On their own, filter() and map() are powerful tools. You can add reduce() to the sequence as well, despite the fact that it isn't lazy. However, this doesn't stop the map() and filter() calls from executing lazily:
const capitalize = s => `${s.charAt(0).toUpperCase()}${s.slice(1)}`;const pick = (m, ...props) => props.map(p => m.get(p));const myList = List.of( Map.of('first', 'joe', 'last', 'brown', 'age', 45), Map.of('first', 'john', 'last', 'smith', 'age', 32), Map.of('first', 'mary', 'last', 'wise', 'age', 56));console.log('myList', myList.toJS());// -> myList [ { first: 'joe', last: 'brown', age: 45 },// -> { first: 'john', last: 'smith', age: 32 },// -> { first: 'mary', ...Read now
Unlock full access