size
优质
小牛编辑
143浏览
2023-12-01
Gets the number of elements in the sequence. In some cases, this may require eagerly evaluating the sequence.
Signature
Sequence.size = function() { /*...*/ }
Sequence.size = function size() { return this.getIndex().length(); }
Name | Type(s) | Description |
---|---|---|
returns | number | The number of elements in the sequence. |
Examples
Lazy([1, 2, 3]).size(); // => 3 Lazy([1, 2]).map(Lazy.identity).size(); // => 2 Lazy([1, 2, 3]).reject(isEven).size(); // => 2 Lazy([1, 2, 3]).take(1).size(); // => 1 Lazy({ foo: 1, bar: 2 }).size(); // => 2 Lazy('hello').size(); // => 5