Skip to main content
Module

x/lunchbox/src/utils.ts

Component Library 🍱 for Deno πŸ¦• Fresh πŸ‹
Latest
import * as lunchbox from "https://deno.land/x/lunchbox@v0.3.15/src/utils.ts";

This module contains various utility functions.

Variables

This function is a shorthand for classNames.default(...classNames: any[]): string

This function makes final classNames (the result of the cn() function) optional and allows a custom class to be appended or to override it altogether.

Functions

This function uses an object that stores the default values for an interface T. It uses an input object of type Partial with new values to replace matching properties.

When adding class to an element, say: <div class={x} /> and x's value ends up being an empty string (''), the element will render <div class /> and end up with tons of empty class attributes. This function simplifies the code that replaces parts that end up having an empty string and makes them have undefined value.

This function emulates the behavior of Array.prototype.map() in Records. It calls a function passing each entry of the record as an argument.