September 2017
Intermediate to advanced
216 pages
6h 8m
English
Use the take() method to tell sequences that you only want a specific number of results. For example, if a page in your application wants to display 20 values, you could add take(20) to your sequence chain. Where should you add this call? The order of where take() is placed in the chain of method calls can have dramatic effects on the result.
Let's start by creating an infinite sequence, as shown in the following code block:
import { Range } from 'immutable';const myRange = Range();
Here, Range is a special type of sequence that's handy for creating large sequences of numbers. Now let's create a predicate function to include only odd numbers:
const predicate = i => i % 2;
Let's see what happens when we place ...
Read now
Unlock full access