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

@bearz/env

v0.1.3

Published

The env provides a uniform way to work with environment variables and the path variable across different runtimes and operating systems.

Readme

@bearz/env

Overview

The env provides a uniform way to work with environment variables and the path variable across different runtimes such as bun, node, deno, cloudflare and the browser and different operating system differences.

Cloudflare and the brower uses an in memory store.

Bash and Windows style variable expansion is included. The env object provides additional methods to convert values to boolean, int, number, json, etc.

logo

JSR npm version GitHub version

Documentation

Documentation is available on jsr.io

A list of other modules can be found at github.com/bearz-io/js

Usage

import * as  env from "@bearz/env";

// get values
console.log(env.get("USER") || env.get("USERNAME"));

// set variable
env.set("MY_VAR", "test")
console.log(env.get("MY_VAR"))

// expansion
console.log(env.expand("${MY_VAR}")); // test
console.log(env.expand("${NO_VALUE:-default}")); // default
console.log(env.get("NO_VALUE")); // undefined

env.expand("${NO_VALUE:=default}"); // default
console.log(env.get("NO_VALUE")); // default

try {
    env.expand("${REQUIRED_VAR:?Environment variable REQUIRED_VAR is missing}");
} catch(e) {
    console.log(e.message); // Environment variable REQUIRED_VAR is missing 
}

// proxy object to allow get/set/delete similar to process.env
console.log(env.proxy.MY_VAR);
env.proxy.MY_VAR = "test"
console.log(env.proxy.MY_VAR)

// undefined will remove a value
env.merge({
    "VAR2": "VALUE",
    "MY_VAR2": undefined
});

// union only sets values that are not undefined and does not already have a value
// in the example below only NEW will be set.
env.union({
    "VAR2": undefined,
    "NEW": "TEST",
    "MY_VAR": "A"
})

env.set("MY_VAR", "test")
env.remove("MY_VAR");

// append to the end of the environment path variables
env.appendPath("/opt/test/bin");

// prepends the path
env.prependPath("/opt/test2/bin");
env.hasPath("/opt/test2/bin");

// removes the path. on windows this is case insensitive.
env.removePath("/opt/test2/bin");

// replaces the path.
env.replacePath("/opt/test/bin", "/opt/test2/bin")

console.log(env.splitPath()); 
console.log(env.getPath()) // the full path string

const path = env.getPath();
// overwrites the environment's PATH variable
env.setPath(`${path}:/opt/test4/bin`) 

Variables

  • proxy - A proxy object that lets you interact with environment variables the way you would with process.env.

Functions

  • appendPath - Appends a path to the PATH environment variable.
  • expand - Expands string template with environment variables.
  • get - Gets an environment variable.
  • getPath - Gets the environment PATH value.
  • has - Determines if an environment variable is set.
  • hasPath - Determines if the PATH variable contains a path.
  • home - Gets the home environment variable value.
  • hostname - Gets the hostname environment variable value.
  • joinPath - Joins paths into a single string.
  • merge - Merges the values from an object into the environment variables.
  • prependPath - Prepends a path to the PATH variable.
  • set - Sets an environment variable.
  • setPath - Sets the environment's PATH value.
  • remove - Deletes an environment variable.
  • removePath - Removes a path from the environment PATH value.
  • replacePath - Replaces a path from the environment PATH value.
  • splitPath - Splits the PATH variable into a string array.
  • shell - Gets the shell environment variable value.
  • os - Gets the os environment variable value.
  • toObject - Clones and returns a copy of all environment values.
  • union - Unions the vlaues from an object into the environment variables.
  • user - Gets the user environment variable value.

License

MIT License