Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Iterates through all the persistent handles in the current isolate's heap that have class_ids and returns the ones matching specific class_ids.

License

Notifications You must be signed in to change notification settings

nodesource/persistents-with-classid

Repository files navigation

persistents-with-classid

Iterates through all the persistent handles in the current isolate's heap that have class_ids and returns the ones matching specific class_id.

Installation

npm install persistents-with-classid

Example

const persistents = require('persistents-with-classid');

var iv1, iv2

function onTimeout() {
  clearInterval(iv1);
}

function Me() {}
Me.prototype.timeout = function () {
  clearInterval(iv2);
}

iv1 = setInterval(onTimeout, 20);
iv2 = setInterval(new Me().timeout, 30);

const result = persistents.collect();

function inspect(obj, depth) {
  console.error(require('util').inspect(obj, false, depth || 5, true));
}

inspect(result, 3);

Output

{ '17':
   [ Timer {
       '0': [Function: listOnTimeout],
       _idleNext:
        { _called: false,
          _idleTimeout: 20,
          _idlePrev: [Circular],
          _idleNext: [Circular],
          _idleStart: 130,
          _onTimeout: [Function: wrapper],
          _repeat: [Function: onTimeout] },
       _idlePrev:
        { _called: false,
          _idleTimeout: 20,
          _idlePrev: [Circular],
          _idleNext: [Circular],
          _idleStart: 130,
          _onTimeout: [Function: wrapper],
          _repeat: [Function: onTimeout] },
       msecs: 20 },
     Timer {
       '0': [Function: listOnTimeout],
       _idleNext:
        { _called: false,
          _idleTimeout: 30,
          _idlePrev: [Circular],
          _idleNext: [Circular],
          _idleStart: 130,
          _onTimeout: [Function: wrapper],
          _repeat: [Function] },
       [ ... ]
       msecs: 30 } ] }

API

persistents_with_classid::collect(classIds) → {Object}

Visits all persistents with class id and collects them grouped by class id.

Parameters:
Name Type Argument Description
classIds Array <optional>

filter of class ids of Objects to call back with, defaults to async_wrap providers

Source:
Returns:

a hash table keyed by class ids with each value being an array of objects with that class id i.e.: { classid-x: [ object, object ] }

Type
Object

persistents_with_classid::visit(fn, classIds)

Visits all persistents with class id and calls back with the ones that the user is interested in.

Parameters:
Name Type Argument Description
fn function

function called with each Object matching the class id filter with signature: callback(classid, object)

classIds Array <optional>

filter of class ids of Objects to call back with, defaults to async_wrap providers

Source:

generated with docme

Async Wrap Providers

{ NONE: 0,
  CRYPTO: 1,
  FSEVENTWRAP: 2,
  FSREQWRAP: 3,
  GETADDRINFOREQWRAP: 4,
  GETNAMEINFOREQWRAP: 5,
  JSSTREAM: 6,
  PIPEWRAP: 7,
  PIPECONNECTWRAP: 8,
  PROCESSWRAP: 9,
  QUERYWRAP: 10,
  SHUTDOWNWRAP: 11,
  SIGNALWRAP: 12,
  STATWATCHER: 13,
  TCPWRAP: 14,
  TCPCONNECTWRAP: 15,
  TIMERWRAP: 16,
  TLSWRAP: 17,
  TTYWRAP: 18,
  UDPWRAP: 19,
  UDPSENDWRAP: 20,
  WRITEWRAP: 21,
  ZLIB: 22 }

Contributing

To submit a bug report, please create an issue at GitHub.

If you'd like to contribute code to this project, please read the CONTRIBUTING.md document.

Authors and Contributors

Thorsten Lorenz GitHub/thlorenz Twitter/@thlorenz

License & Copyright

persistents-with-classid is Copyright (c) 2016 NodeSource and licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.

About

Iterates through all the persistent handles in the current isolate's heap that have class_ids and returns the ones matching specific class_ids.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •