# ah-preprocessors

> Preprocessors of data provided by ah-collector.

Latest version **0.1.0** (published 2017-03-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install ah-preprocessors
pnpm add ah-preprocessors
yarn add ah-preprocessors
bun add ah-preprocessors
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2017-03-09 |
| First published | 2017-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Thorsten Lorenz |
| Maintainers | thlorenz |

## Links

- npm: https://www.npmjs.com/package/ah-preprocessors
- Repository: https://github.com/nodesource/ah-preprocessors
- Issues: https://github.com/nodesource/ah-preprocessors/issues
- npm.io page: https://npm.io/package/ah-preprocessors

## Dependencies (2)

- [facile-clone](https://npm.io/package/facile-clone.md) ~1.2.0
- [function-scout](https://npm.io/package/function-scout.md) ~0.3.0

## Recent versions

- 0.1.0 (latest) — 2017-03-09

## README

# ah-preprocessors

Preprocessors of data provided by ah-collector.

## Installation

    npm install ah-preprocessors

## [API](https://nodesource.github.io/ah-preprocessors)

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Cloner

Creates a Cloner instance which is just a thin wrapper
on top of [facile-clone](https://github.com/thlorenz/facile-clone) and clones an object preserving Buffers and
strings according to the options supplied.

**Parameters**

-   `$0` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** options applied when cloning objects
    -   `$0.bufferLength` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** determines how many elements of Buffers are
        captured. By default not Buffer data is captured. (optional, default `0`)
    -   `$0.stringLength` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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**

-   `x` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** the object to clone

Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** options specifying if arguments and function source are captured and how they are cloned
    -   `$0.cloner` **[Cloner](#cloner)** used to clone the resource information
    -   `$0.captureArguments` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** if `true` arguments of callbacks
        are captured when they are processed. (optional, default `false`)
    -   `$0.captureSource` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** the activities whose resources should be cleaned
-   `collectFunctionInfo` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String))** the id that identifies the activity whose resource should be cleaned
-   `activities` **[Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)&lt;([Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)), [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>** the activities that contain the activity whose resource should be
    cleaned
-   `collectFunctionInfo` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** if `true` it will collect info of all
    functions found on the hooks resources. (optional, default `false`)

### scoutFunctions

Scouts functions using [function-scout](https://github.com/nodesource/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:

```js
 [ { 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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** the context that should be scouted for functions
-   `uid` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the id which is appended to each function info
-   `$0` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** options specifying if arguments and function source are captured and how they are cloned
    -   `$0.captureArguments` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** if `true` arguments of callbacks
        are captured when they are processed. (optional, default `false`)
    -   `$0.captureSource` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** if `true` the source code of callbacks
        is captured when they are processed. (optional, default `false`)
    -   `$0.cloner` **[Cloner](#cloner)** used to clone the function arguments
    -   `$0.name` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)?** if supplied it will be prepended to all function paths (optional, default `null`)

Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>** array of function information elements, one for each function encountered

## License

MIT

---
_Source: https://npm.io/package/ah-preprocessors · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
