0.1.2 • Published 7 years ago
array-flick v0.1.2
array-flick 
Never ending flick though arrays by using next() / prev()
Install
$ npm install array-flickUsage
const Flick = require('array-flick');
const flick = new Flick(1,2,3)
flick.next(); // 1
flick.next(); // 2
flick.next(); // 3
flick.next(); // 1
flick.next(); // 2
flick.prev(); // 1
flick.prev(); // 3
flick.prev(); // 2
flick.random() // one of 1,2,3Note there is also a setter for randomFn. again, useful for testing / seeding. Look at the specs to learn more.
API
new Flick(...values)
Behaves like an Array with next and prev methods added.
When writing database seeders and tests this expressiveness-sugar helps to make the intentions of the program easily recognizable.
next()
Type: Integer
Default: 1
How many steps to flick forward. Defaults to 1.
const names = new Flick('Jim', 'Fin', 'Lin');
names.next() // Jim
names.next(2) // Lin
names.next(2) // Finprev()
Type: Integer
Default: 1
How many steps to flick backwards. Defaults to 1.
const names = new Flick('Jim', 'Fin', 'Lin');
names.prev() // Lin
names.prev(2) // Jim
names.prev(2) // Finrandom()
const xos = new Flick(...(Array(99).fill('x').concat('o')));
xos.randomFn = () => 0.999; // generate your own (seeded) random floats 0..1 here
xos.random() // 'o'Returns a random entry
randomFn (setter)
Useful for reproducible random return values, for example with the help of seedrandom
Contributing 
License
MIT © iilei • Jochen Preusche
0.1.2
7 years ago
0.1.1
7 years ago
0.1.0
7 years ago
0.0.4
7 years ago
0.0.3
7 years ago
0.0.1-beta.0
7 years ago
0.0.1-beta
7 years ago