of-the-day

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i of-the-day

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

3.62 kB

Total Files

4

Last publish

Collaborators

  • seanmcp