@zthun/helpful-fn
v11.0.0
Published
Helpful, isolated pure functions that are not found in other libraries such as lodash.
Readme
Helpful Functions
Provides a basic set of JavaScript functions and classes that are not a part of the JavaScript engine or lodash.
Helpful Functions can be used in Node.js as well as browsers.
Installation
# NPM
npm install @zthun/helpful-fn
# Yarn
yarn add @zthun/helpful-fnFeatures
Import the public exports shown in each feature guide from @zthun/helpful-fn.
Type-only exports can be imported with import type.
| Feature | Description | | ---------------------------------------------- | --------------------------------------------------------------------------------------------------- | | anchor | Define anchor points for alignment and positioning in two-dimensional space. | | assert | Collect failed claims and throw an error after checking them all. | | cast | Normalize values into enum values, file extensions, numbers, or supplier functions. | | cookie | Describe cookies and construct cookie data with a fluent builder. | | count-buckets | Calculate how many buckets or pages are needed for a number of items. | | create-error | Convert error responses and other problem values into JavaScript errors. | | create-guid | Generate random UUID strings. | | culture | Discover the current locale and the locale codes supported by the package's date helpers. | | date | Parse, guess, and format date values with locale and timezone options. | | detokenize | Replace interpolation tokens in text using a dictionary. | | email | Build email contacts, address lists, envelopes, and messages as data objects. | | empty | Check for nullish values and objects with no enumerable own string keys. | | enum | Check enum values and associate them with display metadata. | | file-size | Convert binary file-size units into bytes. Each conversion rounds up to a whole byte. | | first-where | Select the first matching value from an argument list, with a fallback. | | function | Describe functions that supply values without taking arguments. These exports are TypeScript types. | | geometry | Describe points, sides, and corners, and calculate rectangle dimensions and placement. | | global | Access the global object without referring to DOM-specific globals. | | join-defined | Join values into strings while omitting nullish values and conditionally excluded items. | | lazy | Initialize an asynchronous value on demand and reuse its promise. | | mutable | Remove readonly modifiers from TypeScript object types. These types do not modify runtime objects. | | number | Describe numeric values and values that may be converted to numbers. | | obligation | Resolve values or promises while enforcing required values or applying optional fallbacks. | | optional | Express nullability in TypeScript types. | | orientation | Represent horizontal and vertical layout directions. | | partial | Make nested properties optional at the TypeScript type level. | | peel | Split matching prefixes or balanced delimiters from the start of text. | | pick | Copy selected enumerable own string-keyed properties into a new object. | | purge | Remove an explicitly undefined property from an object. | | required | Require nested properties or selected keys at the TypeScript type level. | | serialize | Serialize values, parse JSON, and compose deserializers. | | server | Describe a server connection and build its configuration. | | set-first | Adapt an array of values to a setter that accepts one value. | | sleep | Wait asynchronously using a timer. | | tag | Tag template literals with language names for editor syntax highlighting. | | try | Return fallbacks when operations throw, promises reject, or JSON input cannot be parsed. |
