randpick.js
从数组和字符串中获取随机项。
安装
$ npm install randpick.js
用法
const randpick = require ( 'randpick.js' ) ;
const emoji_array = [ ':bug:' , ':snail:' , ':hatching_chick:' , ':turtle:' , ':shark:' , ':spouting_whale:' , ':sauropod:' , ':lizard:' , ':cow:' , ':otter:' , ':T-Rex:' , ':parrot:' ] ;
// An empty parameter equals 1.
randpick . random ( emoji_array ) ;
//=> ':spouting_whale:'
// .random picks random items from an array and returns a new one.
randpick . random ( emoji_array , 3 ) ;
//=> [
1