A strongly-typed utility library for TypeScript
Install the package using npm.
npm i @appsweet-co/ts-utils
Import utilities directly into your files as needed.
import { clamp, map, sub } from '@appsweet-co/ts-utils';
📝 NOTE: Support for Deno is a work in progress.
Export the package from your deps.ts
file directly from GitHub.
export * from "https://raw.githubusercontent.com/Appsweet-co/ts-utils/index.ts";
Import utilities in your files as needed.
import { clamp, map, sub } from "../deps.ts";
We use TypeDoc to generate API docs. Visit the docs website for details.
Mutated data is hard to work with. Use immutable data instead.
Pure Functions are easy to test and work well with immutable data. They're also referentially transparent and easy for JavaScript engines to optimize.
We write functions that take exactly one argument. We curry all functions as needed.
Return fallbacks instead of undefined or throwing errors.
Passing data as the last argument of a function is great for piping and currying, but TypeScript's typing system works best when we pass in data as the first argument.
We pass fallback values as the first argument and actual data as the last. This helps TypeScript understand the code while still allowing for piping and currying.
Please see the API docs for example code.