logicalahara / of-the-day

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

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

License:MIT License


Languages

Language:JavaScript 100.0%