Skip to main content

Built and signed on GitHub Actions

A set of general-purpose typescript functions for common tasks.

This package works with Bun, Cloudflare Workers, Node.js, Deno, Browsers
JSR Score
94%
Published
22 hours ago (0.0.19)

JSR JSR Score

Toolbox

A set of general-purpose typescript functions for common tasks.

Installation

The toolbox is available via JSR. To install it, run:

npx jsr add @dovca/toolbox

Motivation

The main goal of this package is to remedy the pain of writing readable linear functional code in TypeScript. This package was conceived as a workaround for these issues:

  • Lodash's chain() breaks in production builds. (see issue)
  • TypeScript doesn't support the pipeline operator (yet). (see issue)

One example for all

import {
    add, flow, fromCharCode, grow, increment,
    join, log, map, multiply, toArray,
} from '@dovca/toolbox';

const result = flow(
  1,                 // 1
  add(12),           // 13
  multiply(5),       // 65
  toArray,           // [65]
  grow(increment),   // [65, 66]
  map(fromCharCode), // ['A', 'B']
  join(', '),        // 'A, B'
  log,               // -> console.log('A, B')
);

result; // 'A, B'

Used nomenclature

  • flowing value - the value that is being passed through the flow and pipe functions
  • to produce a value - a function produces a value that then becomes the flowing value
  • predicate - a unary function that "passes" when it returns true for a given value
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @dovca/toolbox

Import symbol

import * as mod from "@dovca/toolbox";

Add Package

npx jsr add @dovca/toolbox

Import symbol

import * as mod from "@dovca/toolbox";

Add Package

yarn dlx jsr add @dovca/toolbox

Import symbol

import * as mod from "@dovca/toolbox";

Add Package

pnpm dlx jsr add @dovca/toolbox

Import symbol

import * as mod from "@dovca/toolbox";

Add Package

bunx jsr add @dovca/toolbox

Import symbol

import * as mod from "@dovca/toolbox";