README
randpick.js
Get random items from arrays and strings.
Install
$ npm install randpick.js
Usage
const randpick = require('randpick.js');
const emoji_array = ['🐛', '🐌', '🐣', '🐢', '🦈', '🐳', '🦕', '🦎', '🐄', '🦦', '🦖', '🦜'];
// An empty parameter equals 1.
randpick.random(emoji_array);
//=> '🐳'
// .random picks random items from an array and returns a new one.
randpick.random(emoji_array, 3);
//=> ['🐳', '🐌', '🦖']
// .string An empty parameter equals 1.
randpick.string('Hello World');
//=> ['r']
// .string picks random letters from a string and converts them into an array (spaces excluded).
randpick.string('Hello World', 5);
//=> ['o', 'e', 'H', 'd', 'W']
// .follow picks a random item from an array plus a custom amount of items following the random one.
// It starts picking from the beginning if there are not enough items left in the array.
randpick.follow(emoji_array, 4);
//=> ['🦦', '🦖', '🦜', '🐛', '🐌']
// .followEnd works just like .follow but it doesn't pick items from the beginning when there are no more items left.
randpick.followEnd(emoji_array, 4);
//=> ['🦦', '🦖', '🦜']
Author
Authored and maintained by 0rso.
GitHub @0rso