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

@the_glitch_master/jstools

v1.3.0

Published

Javascript Utilities

Downloads

452

Readme

jstools

jstools/async

AsyncLock

A mutex designed to allow safe concurrent access of shared values.

Example

const lock = await AsyncLock.new("myLock");

await lock.acquire();
// do work
lock.release();

const v = await lock.with(async () => {
    // do work
});
if (v instanceof Error) throw v;

AsyncLock.new

Description

Create a new AsyncLock with AsyncLock.new. Example:

const lock = await AsyncLock.new("myLockName");

Arguments

| Argument | Type | Description | | -------- | ---- | ----------- | | name | string | The name for the lock (used for error contents) | | disallowReentry? | boolean (=false) | Whether the same async context can acquire the lock multiple times |

Type

class AsyncLock {
static async new(name: string, disallowReentry: boolean = false): AsyncLock {};
}

AsyncLock.acquire

Description

Acquire the lock, or wait until it can be acquired. Example:

const lock = await AsyncLock.new("myLockName");
await lock.acquire();

Type

class AsyncLock {
acquire(): Promise<void> {};
}

AsyncLock.release

Description

Release the lock. Example:

const lock = await AsyncLock.new("myLockName");
await lock.acquire();
// do work
lock.release();

Type

class AsyncLock {
release(): void {};
}

AsyncLock.with

Description

Acquire the lock, run a block of code, release the lock and return the value returned by the block of code (if any), or an error (if any error was thrown).

Type

class AsyncLock {
with(fn: () => Promise<Empty>): Promise<Empty | Error | any> {};
}

getAsyncContextId

Get a unique identifier for the current async context.

Takes no arguments, returns a number.

jstools/errors

| Error | Description | | ----- | ----------- | | AsyncError | Async-related errors | | RuntimeError | Runtime errors | | AsyncRuntimeError | Async-related runtime errors | | DeadlockError | Potential deadlocks | | AsyncDeadlockError | Async-related potential deadlocks | | RuntimeAsyncDeadlockError | Runtime async-related potential deadlocks | | TypeConversionError | Error during type conversions | | LogicError | Failed assertion or unexpected value |

These errors are not specific to this library, so feel free to use them yourself!

jstools/types

int.toString()

Arguments:

  • n: number?

Returns: string | "(undefined)" | "(math.inf)" | "-(math.inf)" | "NaN"

Description:

Safely convert a number to a string (correctly handles inf/nan values and undefined values)

int.toHex()

Arguments:

  • n: number?
  • signed: boolean = false (whether to not convert to an unsigned integer)

Returns: HexString | "0xinf" | "-0xinf" | "NaN"

Description:

Safely convert a number to a hex string (correctly handles inf/nan values and undefined values)

int.toOctal()

Arguments:

  • n: number?
  • signed: boolean = false (whether to not convert to an unsigned integer)

Returns: OctalString | "0oinf" | "-0oinf" | "NaN"

Description:

Safely convert a number to an octal string (correctly handles inf/nan values and undefined values)

hex.toInt()

Arguments:

  • h: HexString?

Returns: number Description:

Safely convert a hex string into a number

hex.toIntAsString()

Arguments:

  • h: HexString?

Returns: string | "(undefined)" | "(math.inf)" | "-(math.inf)" | "NaN"

Description:

Convert a hex string into an integer and then into a string

hex.asString()

Arguments:

  • h: HexString?

Returns: string | "(undefined)"

Description:

Converts the raw contents of a hex string into an ordinary string

octal.toInt()

Arguments:

  • h: HexString?

Returns: number Description:

Safely convert an octal string into a number

octal.toIntAsString()

Arguments:

  • h: HexString?

Returns: string | "(undefined)" | "(math.inf)" | "-(math.inf)" | "NaN"

Description:

Convert an octal string into an integer and then into a string

octal.asString()

Arguments:

  • h: HexString?

Returns: string | "(undefined)"

Description:

Converts the raw contents of an octal string into an ordinary string