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

safer-env

v0.1.1

Published

The whole environment as frozen namespace.

Readme

safer-env

Social Media Photo by freestocks.org on Unsplash

Build Status Coverage Status WebReflection status

The whole environment as frozen namespace.

Background

There is a get-originals proposal which aim is to ensure developers they can trust the method, class, or value they expect, without ever being bothered by possible wraps, polyfill, patches, malicious attacks, and so on and so fort.

This module basically delivers the same proposal but through a one-off crawling of the environment it's running into.

Bear in mind the crawling might be expensive, so use this module, on top of any other, and only if you need it.

The only module that might make sense to include upfront is the @ungap/global-this one.

The Exported Env

The object is frozen in all its level, and it contains native version, or better, the version encountered when it's imported, which is why it should be imported before anything else, of pretty much everything.

// points at the native Object
// since returning Function for every constructor
// was kinda useless anyway
env.Object.constructor;

// points at the native Object.prototype
env.Object.prototype.toString;

// simulate safer-function
let {call} = env.Function.prototype;
const bind = call.bind(call.bind);
const apply = bind(call, call.apply);
call = bind(call, call);

call(env.Object.prototype.toString, '');
// [object String]

Getters and Setters

Everything is stored either directly or through an object that might expose {get}, {set}, or both {get, set}.

As example, Element.prototype.innerHTML.set is the setter able to add HTML content to a node.

About performance and usage

It's unfortunately useless to lazy load anything through proxies or getters, because the purpose is to be sure that whatever is encountered when the module is included, will be frozen forever within the module content.

This makes it mandatory to include this module ASAP on top of your project, and put the script on top of any other script, otherwise there's nothing really safer in using this module.

Due absence of lazily crawled namespaces, classes, and prototypes, one off creation performance might vary from device in device so please test on target browsers and common hardware too.

The Future Is Bright

The day std:global and get originals proposal will land, the refactoring should be straight forward:

// before
const { apply } = env.Reflect;

// after
import { apply } from "std:global/Reflect";

A simple RegExp might already be enough to change that in the future.

script.replace(
  /\b(const)\b(\s+\{.+?}\s*)(=)(\s*)(env\.)(.+)?;/g,
  ($0, $1, $2, $3, $4, $5, $6) => `import${$2}from${$4}"std:global/${$6}";`
);