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

forensics

v0.0.5

Published

Clean, simple analytics.

Downloads

8

Readme

Forensics

npm i forensics

const Forensics = require("forensics");
let detective = new Forensics();
const express = detective.track(require('express'));
const dbController = detective.track(require('./fakeThing'));
const sum = detective.trackFunction((a,b) => a + b);

sum(1, 2); sum(3,4); sum(5,6);
dbController.getUserById('3'); //Forensics can only track direct return values

invalidFunctionToKillProcess()
//Detective writes report to ./autopsy.txt

class: Forensics({[autopsy function], [filePath path]})

Creates a new instance of a forensics object. If it's the first within the application context, it creates a whole new one, else it points its references to the first instance.

If it's necessary to create a whole new instance, use Forensic.createNew({[autopsy function], [filePath path]})

forensics.trackObject(anything)

Returns a tracked object. Should be used for construction of objects and functions.

forensics.trackFunction(fn)

Used for functions, but maps back to trackObject

Forensics.instance

Return instance of instantiated forensics object or undefined

Forensics.createNew(same as constructor)

Create a new instance of a forensics object


class: ObjectTracker

Monitored proxy objects

objectTracker.isProxy === true

objectTracker.isObjectProxy === true

objectTracker.trackedObjects

user.options.tooling = false

Gets objects that are contained by the root objectTracker and how many times they've been accessed. They will also be turned into ObjectTracker instances

objectTracker.trackedFunctions

user.getFriends()

Gets functions contained by the root object that are being monitored. Each function becomes a tracked function once invoked or retrieved.

objectTracker.trackedPrimitives

console.log(user.name) tracked primitives and their return values

objectTracker.getDeepTrackedObjects()

user.getDeepTrackedObjects()

Gets nested tracked objects and returns it as a flat array

objectTracker.comprehensive()

user.comprehensive()

returns all of the above as an object

objectTracker.dump([callback])

user.dump(cb(trackedObjects, trackedFunctions, trackedPrimitives));

Resets all tracked properties for memory purposes for long running applications. Callback is invoked on old trackedObjects, trackedFunctions, and trackedPrimitives

class: FunctionTracker

Monitored function objects Tracks duration of function call, cpu usage, arguments, and duration.

functionTracker.isProxy === true

sum.isProxy

functionTracker.isFunctionProxy === true

sum.isFunctionProxy

functionTracker.calibrate(testFn)

sum.calibrate(result => typeof result === 'number') A test function which when returns false, will pass the failure into an array of failed function calls. Can be used to validate results on the fly.

functionTracker.misfires

sum.misfires === ['ab', null, undefined] Array of arguments and results that did not pass the test provided by calibrate

functionTracker.fingerprints

sum.fingerprints //object Array of all invokations of the function with arguments, duration, cpu usage, and results.

functionTracker.comprehensive()

sum.comprehensive() returns all of the above as an object

functionTracker.dump([callback])

sum.dump(cb(misfires, fingerprints)); Resets misfires and fingerprints for memory purposes. The callback ins invoked with old misfires and fingerprints


MIT