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 🙏

© 2025 – Pkg Stats / Ryan Hefner

deep-proxy-monitor

v0.3.2

Published

A simple library to monitoring the access to all the properties including nested properties in arrays and objects using the Proxy ES6 implementation.

Readme

deep-proxy-monitor

A simple library to make nested proxies and monitoring the access to every single properties of an object including nested ones from arrays and objects.

This is useful for detect unused properties of an input object data to improve performance issues on large projects with a bunch of data.

Is recommended use only for development stages until the library could be ready for production scenarios and testing the performance cases.

Installation

npm install --save-dev deep-proxy-monitor

Usage example

deepProxy

By using the deepProxy function you can create a nested proxy to trap the access to any nested element inside the target object:

// CommonJS
const { deepProxy } = require('deep-proxy-monitor')

// or ESM
import { deepProxy } from 'deep-proxy-monitor'

const testObj = {
  foo: 'foo',
  bar: [{
    baz: 'baz',
    zoo: {
      cat: 'cat'
    }
  }]
}

const handler = {
  get: function (target, prop) {
    console.log(`Accessing to ${prop}`)
    return target[prop]
  }
}

const proxy = deepProxy(testObj, handler)

console.log(proxy.foo)
console.log(proxy.bar[0].zoo.cat)

Output:

Accessing to foo
foo
Accessing to bar
Accessing to zoo
Accessing to cat
cat

proxyMonitor

Another important and useful use case is to monitoring the access to all elements of an object by watching the monitor object given by then proxyMonitor function:

// CommonJS
const { proxyMonitor } = require('deep-proxy-monitor')

// or ESM
import { proxyMonitor } from 'deep-proxy-monitor'

const testObj = {
  foo: 'foo',
  bar: [{
    baz: 'baz',
    zoo: {
      cat: 'cat'
    }
  }]
}

const [proxy, monitor] = proxyMonitor(testObj)

console.log(proxy.foo)
console.log(proxy.bar[0].zoo.cat)
console.log(JSON.stringify(monitor))

Output:

foo
cat
{"foo":true,"bar":[{"baz":false,"zoo":{"cat":true}}]}

The default handler for the proxyMonitor function is to assign true or false when an element is accessed or not. You can customize the handler function passing a second argument to the proxyMonitor function like:

// CommonJSo
const { proxyMonitor } = require('deep-proxy-monitor')

// or ESM
import { proxyMonitor } from 'deep-proxy-monitor'

const testObj = {
  foo: 'foo',
  bar: [{
    baz: 'baz',
    zoo: {
      cat: 'cat'
    }
  }]
}

const monitorStrategy = {
  initialValue: 0,
  strategy: (objToMonitor, prop) => {
    // count the number of element access
    if (typeof objToMonitor[prop] === 'number') {
      ++objToMonitor[prop]
    }
  }
}

const [proxy, monitor] = proxyMonitor(testObj, monitorStrategy)

console.log(proxy.foo)
console.log(proxy.bar[0].zoo.cat)
console.log(JSON.stringify(monitor))

Outputs

foo
cat
{"foo":1,"bar":[{"baz":0,"zoo":{"cat":1}}]}

For more examples, you can see the tests cases inside the test folder.

Author

Stevens Pineda – @ScolDev[email protected]

Distributed under the MIT license. See LICENSE for more information.

Contributing

  1. Fork it (https://github.com/ScolDev/deep-proxy-monitor/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request