npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@simpill/function.utils

v1.0.0

Published

Debounce, throttle, once, pipe, and compose with TypeScript inference (Node and Edge).

Readme

Features: Type-safe · Node & Edge · Tree-shakeable


Installation

From npm

npm install @simpill/function.utils

From GitHub

To use this package from the monorepo source:

git clone https://github.com/SkinnnyJay/simpill.git
cd simpill/utils/@simpill-function.utils
npm install && npm run build

In your project you can then install from the local path: npm install /path/to/simpill/utils/@simpill-function.utils or use npm link from the package directory.


Quick Start

import { debounce, throttle, once, pipe, compose } from "@simpill/function.utils";

const save = debounce(doSave, 300);
const onScroll = throttle(handler, 100);
const load = once(fetchConfig);
const transform = pipe(trim, toLower, capitalize);
const transform2 = compose(capitalize, toLower, trim);

Features

| Feature | Description | |---------|-------------| | Debounce | Invoke after a wait with no further calls | | Throttle | At most one call per wait period | | Once | Run only the first time | | Pipe / Compose | Left-to-right (pipe) or right-to-left (compose) composition; sync only — use pipeAsync from @simpill/patterns.utils for async | | Arguments | spreadArgs, fillArgs, requireArgs, firstArg, lastArg, restArgs | | Annotations | setAnnotation, getAnnotation, hasAnnotation, deleteAnnotation, getAnnotations — metadata on any object | | noop | No-op helper |


Import Paths

import { ... } from "@simpill/function.utils";         // Everything
import { ... } from "@simpill/function.utils/client";  // Client
import { ... } from "@simpill/function.utils/server";  // Server
import { ... } from "@simpill/function.utils/shared";  // Shared only

API Reference

  • debounce(fn, wait) → returns a CancellableFunction: same signature plus .cancel(), .flush(), .pending(). No leading/trailing/maxWait; invokes only after wait ms of no further calls.
  • throttle(fn, wait, options?) → ThrottleOptions: leading (default true), trailing (default true). Returns CancellableFunction with .cancel(), .flush(), .pending().
  • once(fn) → runs fn only on the first call; every subsequent call returns the same cached result. No reset — there is no API to “run again”.
  • pipe(...fns) → composed function (left-to-right: first fn applied first). Sync only; for async pipelines use pipeAsync from @simpill/patterns.utils.
  • compose(...fns) → composed function (right-to-left). Sync only.
  • pipeWith / composeWith → typed overloads for pipe/compose with distinct input/output types.
  • spreadArgs(args), fillArgs(template, values), requireArgs(args, count), firstArg/ lastArg/ restArgs(args, from?) — argument helpers (see below).
  • setAnnotation(target, key, value), getAnnotation(target, key), hasAnnotation, deleteAnnotation, getAnnotations — metadata on objects (validation, DI, plugins).
  • noop() → no-op function

This binding

debounce, throttle, and once do not preserve this. For methods, wrap: debounce(() => obj.method(), 100) or pass a bound function: debounce(obj.method.bind(obj), 100).

Once behavior

The returned function is idempotent after the first call: same arguments or different, it always returns the first result. Useful for lazy init or single-run setup; not for “run once per session” reset — use your own wrapper if you need reset.

Arguments helpers

  • spreadArgs(args) — convert arguments or array to a real array.
  • fillArgs(template, values) — copy template and overwrite by index, e.g. fillArgs([0, 0], { 1: 2 })[0, 2].
  • firstArg/ lastArg/ restArgs(args, from?) — first element, last element, or slice from index.

Annotations use cases

Attach metadata to any object without modifying its prototype: validation schema keys, DI tokens, plugin IDs, or feature flags. Keys are string-based; use a namespace prefix to avoid collisions (e.g. "myapp:validator"). Same store is used by @simpill/annotations.utils for a richer API.

What we don’t provide

  • Memoize — No memoization helper. Use memoize / memoizeAsync from @simpill/cache.utils or @simpill/misc.utils for result caching by arguments.
  • Curry / partial — No curry or partial. Use Function.prototype.bind for partial application, or a library (e.g. lodash) for full curry.
  • Before / after hooks — No wrapper that runs a function before or after another. Compose manually: (...args) => { before(); return fn(...args); } or use a small wrapper with pipe/compose if you need ordered side effects.

Examples

npx ts-node examples/01-basic-usage.ts

| Example | Description | |---------|-------------| | 01-basic-usage.ts | debounce (cancel/flush), throttle, once, pipe (trim → toLower → capitalize) |


Development

npm install
npm test
npm run build
npm run verify

Documentation


License

ISC