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

@spinajs/util

v2.0.533

Published

utility functions shared across @spinajs framework

Readme

@spinajs/util

Utility functions shared across the @spinajs framework — argument validation, functional/async combinators, a TimeSpan duration type, a Polly-style resilience pipeline, and an assortment of small helpers.

import { TimeSpan, ResiliencePipelineBuilder, _check_arg, sleep } from '@spinajs/util';

Everything is re-exported from the package root; import by name.

Documentation

| Scope | Docs | What's inside | |---|---|---| | Resilience | documentation/resilience.md | retry, timeout, circuit breaker, fallback, hedging, concurrency limiter; pipeline builder; PredicateBuilder; cancellation | | TimeSpan | documentation/timespan.md | immutable duration type: construction, parsing, arithmetic, comparison, Date/Luxon interop, formatting | | Args validation | documentation/args.md | _check_arg + composable validate/transform checks | | FP / async | documentation/fp.md | _chain, _zip, _map, _use, _tap, _either, error combinators | | Process | documentation/process.md | sleep/withTimeout, graceful shutdown, typed env parsing | | Assertions | documentation/assert.md | type-narrowing runtime asserts | | Core helpers | documentation/utilities.md | array, hash, json, string, func, types |

Highlights

Resilience — compose strategies into a reusable pipeline:

const pipeline = new ResiliencePipelineBuilder<Buffer>()
  .addTimeout(TimeSpan.fromSeconds(10))
  .addRetry({ MaxRetryAttempts: 3, BackoffType: BackoffType.Exponential, UseJitter: true })
  .build();

const data = await pipeline.execute(() => downloadAsync());

TimeSpan — an immutable duration accepted anywhere a TimeSpanLike is expected:

TimeSpan.fromHours(2).add(TimeSpan.fromMinutes(30)).toString(); // '02:30:00'
TimeSpan.parse('1.02:30:45')?.totalHours;                        // 26.5125

Args — validate and normalize inputs at a boundary:

const email = _check_arg(_is_string(), _trim(), _to_lower(), _is_email())(input, 'email');

Development

npm run build    # compile (tsc) to lib/mjs
npm test         # run the mocha/ts-node test suite

Coverage note: npm run coverage runs nyc, but the repo does not currently configure istanbul instrumentation for the ESM + ts-node test setup, so it reports 0%. The suite itself covers every source module; wiring up @istanbuljs/nyc-config-typescript would restore real numbers.

License

MIT