![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
One straight forward function that returns a random item
from an array 😍
npm i @ssts/item
import seniorITEM from "@ssts/item";
const randomItem = seniorITEM(["Item 1", "Item 2", "Item 3"]);
Returns a random item from an array or undefined if the array is empty
Order | Parameter | Type | Default |
---|---|---|---|
1 | array | any[] | required |
import seniorITEM from "@ssts/item";
const snacks = ["Peanuts", "Chips", "Candy", "Chocolate", "Popcorn", "Cookies", "Donuts", "Ice cream", "Yogurt", "Brownies", "Cupcakes", "Gummies", "Muffins", "Your favorite drink lol"] as const;
const randomSnack = seniorITEM(snacks);
console.log(randomSnack); // 'Chips'
type Snacks = (typeof snacks)[number];
// It's okay With/Without a generic
console.log(seniorITEM(snacks)); // 'Cookies'
console.log(seniorITEM<Snacks>(snacks)); // 'Candy'
type Item = {
key: string;
name: string;
imgSrc: string;
};
type Items = Item[];
const items: Items = [/* ... */];
console.log(seniorITEM([])); // undefined
console.log(seniorITEM(items)); // { key: "17", name: "Item 17", imgSrc: "https://picsum.photos/200" }
console.log(seniorITEM<Item>(items)); // { key: "5", name: "Item 5", imgSrc: "https://picsum.photos/200" }
Made With Chocolate By Senior Sedo 😎
Be Chocolateful 💙😍
ssts stands for senior-sedo-typescript 💙
So instead of
@senior-sedo-typescript/rand-item
@ssts/item
for simplicity sake 😍
FAQs
Get a random item from an array.
The npm package @ssts/item receives a total of 1 weekly downloads. As such, @ssts/item popularity was classified as not popular.
We found that @ssts/item demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.