https://github.com/yornaath/cycle-chunk
Cycle indefinitely through chunks of an array
https://github.com/yornaath/cycle-chunk
Last synced: 3 months ago
JSON representation
Cycle indefinitely through chunks of an array
- Host: GitHub
- URL: https://github.com/yornaath/cycle-chunk
- Owner: yornaath
- Created: 2018-04-03T12:15:14.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-03T20:14:30.000Z (over 7 years ago)
- Last Synced: 2025-03-15T17:43:17.875Z (7 months ago)
- Language: TypeScript
- Size: 68.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# cycle-chunk [](https://travis-ci.org/gorillatron/cycle-chunk.svg?branch=master)
Cycle through an array indefinetly providing a chunk of custom size per iteration.
Usefull in showing slideshows, panels, tabs and so forth.**Install:**
```bash
npm i cycle-chunk
```**Example:**
```js
import CycleChunk from 'cycle-chunk'const cyclechunk = new CycleChunk([1,2,3,4,5,6,7], 3)
cyclechunk.next() == [1,2,3]
cyclechunk.next() == [4,5,6]
cyclechunk.next() == [7,1,2]cyclechunk.prev() == [4,5,6])
cyclechunk.prev() == [1,2,3])
cyclechunk.prev() == [5,6,7])
```# API
## class CycleChunk\ extends Array
### **constructor(array:T[], size?: number = 0, startIndex?: number = 0)**
### **next():T[]**
### **prev():T[]**
### **current():T[]**
### **public reversed: IterableIterator**
### **public \* \[Symbol.iterator\]():IterableIterator**