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

ah-preprocessors

v0.1.0

Published

Preprocessors of data provided by ah-collector.

Downloads

4

Readme

ah-preprocessors

Preprocessors of data provided by ah-collector.

Installation

npm install ah-preprocessors

API

Cloner

Creates a Cloner instance which is just a thin wrapper on top of facile-clone and clones an object preserving Buffers and strings according to the options supplied.

Parameters

  • $0 Object options applied when cloning objects
    • $0.bufferLength number? determines how many elements of Buffers are captured. By default not Buffer data is captured. (optional, default 0)
    • $0.stringLength number? determines how much of each string is captured. By default no string data is captured. (optional, default 0)

cloner.clone

Clones the object according to the options supplied in the constructor.

Parameters

Returns Object the cloned object

ResourceProcesor

Creates an instance of ResourceProcessor. Never call this directly, instead extend it to create a specific processor for your particular resource type, i.e. NetworkResourceProcessor.

Makes sure that each resource is only processed once.

Parameters

  • $0 Object options specifying if arguments and function source are captured and how they are cloned
    • $0.cloner Cloner used to clone the resource information
    • $0.captureArguments Boolean? if true arguments of callbacks are captured when they are processed. (optional, default false)
    • $0.captureSource Boolean? if true the source code of callbacks is captured when they are processed. (optional, default false)

resourceProcessor.cleanAllResources

Cleans up all captured resources which means that they are processed, meaningful data extracted and the reference to the actual resource removed so it can be GCed.

Parameters

  • activities Object the activities whose resources should be cleaned
  • collectFunctionInfo Boolean? if true it will collect info of all functions found on the hooks resources. (optional, default false)

resourceProcessor.cleanupResource

Cleans the particular resource of the activity found by the uid as part of the activities. If the uid isn't found in the activities or the activity is null this function returns without doing anything.

Parameters

  • uid (Number | String) the id that identifies the activity whose resource should be cleaned
  • activities Map<(Number | String), Object> the activities that contain the activity whose resource should be cleaned
  • collectFunctionInfo Boolean? if true it will collect info of all functions found on the hooks resources. (optional, default false)

scoutFunctions

Scouts functions using function-scout and then adapts the data according to the supplied options. In the process clones function arguments as well and appends them to the returned function info

This function is used by the ResourceProcessor and most likely you won't have to call it directly.

Sample return value:

 [ { path: [ 'owner', '_events', 'connection' ],
     key: 'connection',
     level: 2,
     info:
      FunctionOrigin {
        file: '/Volumes/d/dev/js/async-hooks/ah-net/test/one-tcp-server.listen+close.js',
        line: 25,
        column: 21,
        inferredName: '',
        name: 'onconnection' },
     id: 2,
     arguments: null }]

Parameters

  • ctx Object the context that should be scouted for functions
  • uid Number the id which is appended to each function info
  • $0 Object options specifying if arguments and function source are captured and how they are cloned
    • $0.captureArguments Boolean? if true arguments of callbacks are captured when they are processed. (optional, default false)
    • $0.captureSource Boolean? if true the source code of callbacks is captured when they are processed. (optional, default false)
    • $0.cloner Cloner used to clone the function arguments
    • $0.name String? if supplied it will be prepended to all function paths (optional, default null)

Returns Array<Object> array of function information elements, one for each function encountered

License

MIT