π A utility to return items from a shuffled list based on the ISO day
npm install of-the-day
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']
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.
This library is a simple wrapper around knuth-shuffle-seeded
by Timothy Gu.
MIT Β© Sean McPherson