of-the-day
v1.0.0
Published
A utility to return items from a shuffled list based on the ISO day
Downloads
16
Maintainers
Readme
of-the-day
🍜 A utility to return items from a shuffled list based on the ISO day
Install
npm install of-the-day
Usage
import ofTheDay from 'of-the-day';
const color = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];
const colorOfTheDay = ofTheDay(colors)
const colorsOfTheDay = ofTheDay(colors, 3)
console.log(colorOfTheDay, colorsOfTheDay)
// -> ['orange'], ['orange', 'red', 'blue']
And then again tomorrow:
console.log(colorOfTheDay, colorsOfTheDay)
// -> ['green'], ['green', 'purple', 'orange']
Why?
If you want an "item of the day" for your shop, or "today's featured article" on your blog, you can use this utility to reliably return a random item from your list.
Credit
This library is a simple wrapper around knuth-shuffle-seeded
by Timothy Gu.
License
MIT © Sean McPherson