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

nano-audit

v1.2.1

Published

Tiny utility to audit Javascript/Typescript tree of function calls and durations

Downloads

435

Readme

Nano Audit

Tiny utility library to quickly audit Javascript/Typescript tree of function calls and durations.

Like this module? ❤

Please consider:

Usage

// import NanoAudit and instantiate it in your code:

import NanoAudit from 'nano-audit';

const { audit } = new NanoAudit('my-audit');

// then use the `audit` function to audit your code:

const firstFn = () => {
  const auditResult = audit(auditName, `firstFn`);
  const startedAt = Date.now();

  while ((Date.now() - startedAt) < 300) {}

  auditResult.end();
};

const secondFn = () => {
  const auditResult = audit(auditName, 'secondFn');

  firstFn();
  auditResult.end();
};

const thirdFn = () => {
  const auditResult = audit(auditName, 'thirdFn');

  secondFn();
  auditResult.end();
};

firstFn();
secondFn();
thirdFn();

Make sure to set the NANO_AUDIT env var to TRUE:

// i.e. in your .env:
NANO_AUDIT=TRUE

// or when running your app:
$ NANO_AUDIT=TRUE yarn start

Output

# ./my-audit.map.audit
ID      	G_LVLS	FN_LVL	T_STR
611b2f53	000001	000000	> firstFn
611b2f54	000001	000000	> secondFn
611b2f55	000002	000001	>> firstFn
611b2f56	000001	000000	> thirdFn
611b2f57	000002	000001	>> secondFn
611b2f58	000003	000002	>>> firstFn

# ./my-audit.time.audit
ID      	G_LVLS	FN_LVL	T_STR	DURATION
611b2f53	000000	000000	firstFn	301
611b2f55	000001	000001	firstFn	300
611b2f54	000000	000000	secondFn	300
611b2f58	000002	000002	firstFn	300
611b2f57	000001	000001	secondFn	302
611b2f56	000000	000000	thirdFn	302

# NOTE: in the last line of the `.time.audit` files,
#       G_LVLS should ALWAYS end in 000000
#       otherwise it means that an audit failed to
#       call it's `.end()` method

Author Notes

This is NOT meant to be an exhaustive auditing tool, nor am I planning to add any complex features in any foreseeable future.

There are many and better solutions if you wish to audit your JS/TS apps with more detail.

One such example:

https://clinicjs.org/

Cheers 🍺