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

@neotales/process

v0.0.0-alpha.0

Published

Current process utilties with stdio and directory stack support.

Readme

@neotales/process

Overview

Cross-runtime process utilities providing access to process ID, command-line arguments, executable path, current working directory, directory navigation, and standard I/O streams. Works seamlessly with Deno, Node.js, Bun, and has experimental browser support.

logo

JSR npm version GitHub version

Documentation

Documentation is available on jsr.io

A list of other modules can be found at github.com/neotales/js-std

Installation

# Deno
deno add jsr:@neotales/process

# npm from jsr
npx jsr add @neotales/process

# from npmjs.org
npm install @neotales/process

Quick Start

import { args, pid, execPath, cwd, chdir, exit, stdout } from "@neotales/process";

// Access process info
console.log("PID:", pid);
console.log("Args:", args);
console.log("Executable:", execPath());
console.log("Working directory:", cwd());

// Change directory
chdir("../other-project");
console.log("New directory:", cwd());

// Write to stdout
const encoder = new TextEncoder();
stdout.writeSync(encoder.encode("Hello from stdout\n"));

// Exit with code
exit(0);

API Reference

Constants

| Constant | Type | Description | | -------- | ----------------------- | ------------------------------------------------------------ | | pid | number | The process ID of the current process (0 in browser) | | ppid | number | The parent process ID (0 in browser) | | args | ReadonlyArray<string> | Command-line arguments (excludes executable and script path) | | stdin | StdReader | Standard input stream reader | | stdout | StdWriter | Standard output stream writer | | stderr | StdWriter | Standard error stream writer |

import { args, pid, ppid } from "@neotales/process";

// Process ID
console.log(`Running as PID: ${pid}`);
console.log(`Started by PID: ${ppid}`);

// Command-line arguments (e.g., `deno run script.ts --flag value`)
// args = ["--flag", "value"]
for (const arg of args) {
  console.log(`Arg: ${arg}`);
}

Directory Functions

| Function | Description | | ------------------ | ------------------------------------------ | | cwd() | Returns the current working directory | | chdir(directory) | Changes the current working directory | | pushd(directory) | Push directory to stack and change to it | | popd() | Pop directory from stack and change to it | | execPath() | Returns the path to the current executable |

import { cwd, chdir, pushd, popd, execPath } from "@neotales/process";

// Get current directory
console.log(cwd()); // "/home/user/project"

// Change directory
chdir("../other");
console.log(cwd()); // "/home/user/other"

// Use pushd/popd for temporary directory changes
pushd("/tmp");
console.log(cwd()); // "/tmp"
const prevDir = popd();
console.log(prevDir); // "/home/user/project"

// Get executable path
console.log(execPath()); // "/usr/bin/deno" or similar

Process Control

| Function | Description | | ------------- | ------------------------------------------------------ | | exit(code?) | Exits the process with optional exit code (default: 0) |

import { exit } from "@neotales/process";

// Exit successfully
exit(0);

// Exit with error
exit(1);

Standard Streams

| Interface | Methods | | ----------- | --------------------------------------------------------- | | StdWriter | write(chunk), writeSync(chunk), isTerm(), close() | | StdReader | read(data), readSync(data), isTerm(), close() |

On Node.js, close() is a no-op because these streams belong to the host process.

import { stdout, stderr, stdin } from "@neotales/process";

const encoder = new TextEncoder();
const decoder = new TextDecoder();

// Write to stdout
stdout.writeSync(encoder.encode("Output message\n"));
await stdout.write(encoder.encode("Async output\n"));

// Write to stderr
stderr.writeSync(encoder.encode("Error message\n"));

// Check if stream is a terminal
if (stdout.isTerm()) {
  console.log("Running in interactive terminal");
}

// Read from stdin
const buffer = new Uint8Array(1024);
const bytesRead = stdin.readSync(buffer);
if (bytesRead !== null && bytesRead > 0) {
  console.log("Input:", decoder.decode(buffer.subarray(0, bytesRead)));
}

Error Classes

| Class | Description | | ---------------------- | ------------------------------------------------------- | | ChangeDirectoryError | Thrown when chdir() fails (e.g., directory not found) |

import { chdir, ChangeDirectoryError } from "@neotales/process";

try {
  chdir("/nonexistent/path");
} catch (error) {
  if (error instanceof ChangeDirectoryError) {
    console.error("Failed to change directory:", error.message);
  }
}

Browser Support (Experimental)

The browser polyfill provides limited functionality:

| Feature | Browser Behavior | | ------------------ | --------------------------- | | pid | Always returns 0 | | args | Returns empty array | | cwd() | Returns location.pathname | | chdir(path) | No-op | | pushd()/popd() | No-op | | exit() | Calls window.close() | | stdout/stderr | Write to console | | stdin | Returns null for reads |

License

MIT License