of-the-day

A utility to return items from a shuffled list based on the ISO day

Usage no npm install needed!

<script type="module">
  import ofTheDay from 'https://cdn.skypack.dev/of-the-day';
</script>

README

of-the-day

npm npm bundle size (minified) npm

🍜 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