ah-preprocessors v0.1.0
ah-preprocessors
Preprocessors of data provided by ah-collector.
Installation
npm install ah-preprocessorsAPI
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
$0Object options applied when cloning objects
cloner.clone
Clones the object according to the options supplied in the constructor.
Parameters
xObject the object to clone
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
$0Object options specifying if arguments and function source are captured and how they are cloned$0.clonerCloner used to clone the resource information$0.captureArgumentsBoolean? iftruearguments of callbacks are captured when they are processed. (optional, defaultfalse)$0.captureSourceBoolean? iftruethe source code of callbacks is captured when they are processed. (optional, defaultfalse)
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
activitiesObject the activities whose resources should be cleanedcollectFunctionInfoBoolean? iftrueit will collect info of all functions found on the hooks resources. (optional, defaultfalse)
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 cleanedactivitiesMap<(Number | String), Object> the activities that contain the activity whose resource should be cleanedcollectFunctionInfoBoolean? iftrueit will collect info of all functions found on the hooks resources. (optional, defaultfalse)
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
ctxObject the context that should be scouted for functionsuidNumber the id which is appended to each function info$0Object options specifying if arguments and function source are captured and how they are cloned$0.captureArgumentsBoolean? iftruearguments of callbacks are captured when they are processed. (optional, defaultfalse)$0.captureSourceBoolean? iftruethe source code of callbacks is captured when they are processed. (optional, defaultfalse)$0.clonerCloner used to clone the function arguments$0.nameString? if supplied it will be prepended to all function paths (optional, defaultnull)
Returns Array<Object> array of function information elements, one for each function encountered
License
MIT
9 years ago