.limit() - DarthJDG/Mangler.js GitHub Wiki
Truncates the items array to a certain number of items.
.limit(size)| Parameter | Type | Default | Description |
|---|---|---|---|
| size | Number | The number of items to keep. 0 means "unlimited" and keeps all items. |
Returns the mangler object itself for chaining.
Reduces the number of items in the .items[ ] array to the given size by removing all items form the end that go over. A value of 0 means there is no limit, and doesn't change the array. If you want to clear the array, use .clear().
m = Mangler([1, 2, 3, 4])
m.limit(0); // m.items is still [1, 2, 3, 4]
m.limit(2); // m.items = [1, 2]