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 🙏

© 2024 – Pkg Stats / Ryan Hefner

proxur

v0.1.9

Published

Zero config, zero dependency, safe and lightweight (427 bytes gzipped!) proxy supporting both dot syntax and regular syntax.

Downloads

24

Readme

Zero config, zero dependency, safe(r) and lightweight (414 bytes gzipped!) proxy supporting both dot syntax and regular syntax.

Usage

TL;DR: All expected methods for object will work on this proxy. The only difference is that now you can access and set values using dot-path notation, or regular notation. Dot notation is safe both for setting and getting, while using regular notation will throw a TypeError in strict mode for the time being.

import Proxify from "proxur"

let obj = {
  foo: {
    bar: {
      baz: "42"
    }
  },
  arr: [ 1, 2, 3, 4, 5],
  test: {
    test: "test"
  }
}

obj = Proxify(obj)

console.log(obj["foo.bar.baz"]) // 42
console.log(obj.foo.bar.baz) // 42

console.log(obj["x.y.z"]) // undefined
console.log(obj.x.y.z) // undefined - throws a TypeError using the strict mode

obj["arr.0"] = "zero"
console.log(obj.arr[0])

obj.arr[1] = "one"
console.log(obj["arr.1"])

delete obj["test.test"]
console.log(obj["test.test"]) // undefined

const keys = Object.keys(obj)
console.log(keys) // [ "foo", "arr", "test"]

Object.defineProperty(obj, "foo.bar.test", { value: 333333 })
console.log(obj.foo.bar.test) // 333333

Object.preventExtensions(obj)
obj.z = "error" // Throws a TypeError using the strict mode
console.log(z in obj) // false
console.log(Object.isExtensible(obj)) // false

const original = Object.getPrototypeOf(obj)
console.log(original.arr) // [ 1, 2, 3, 4, 5]

const descriptor = Object.getOwnPropertyDescriptor(obj, "foo.bar.test")
console.log(descriptor) // { value: 333333, writable: true, enumerable: true, configurable: true }

If you just need an empty object, you can just call Proxify without any arguments:

const proxifiedObj = Proxify()

Etc. You get the idea.

Also, you will still get a TypeError in strict mode no matter what syntax you use if you try to set a property AFTER having called Object.preventExtensions(obj).