https://github.com/joakin/cycle-values
npm package to cycle through values in an array
https://github.com/joakin/cycle-values
Last synced: 8 months ago
JSON representation
npm package to cycle through values in an array
- Host: GitHub
- URL: https://github.com/joakin/cycle-values
- Owner: joakin
- Created: 2015-03-18T08:54:01.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-18T08:57:59.000Z (about 11 years ago)
- Last Synced: 2025-03-13T10:46:37.784Z (over 1 year ago)
- Language: JavaScript
- Size: 117 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Npm javascript package
cycle-values
============
Cycle through values.
```js
// npm install cycle-values
var cycle = require('cycle-values')
// cycle(Array values = [])
var nums = cycle([1, 2, 3])
// Returns a function that when called will give you a new value
console.log(nums())
// > 1
console.log(nums())
// > 2
// You can pass an offset to the fn to skip or go back
console.log(nums(0))
// > 2
console.log(nums(2))
// > 1
console.log(nums(-1))
// > 3
```
Dev
---
`npm test` for testing the code after doing an `npm install`