How to use the stack-chain.extend function in stack-chain

To help you get started, we’ve selected a few stack-chain examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AndreasMadsen / trace / trace.js View on Github external
let executionScopeDepth = 0;
// Contains the call site objects of all active scopes
const traces = new Map();

//
// Mainiputlate stack trace
//
// add lastTrace to the callSite array
chain.filter.attach(function (error, frames) {
  return frames.filter(function (callSite) {
    const name = callSite && callSite.getFileName();
    return (!name || (name !== 'async_hooks.js' && name !== 'internal/async_hooks.js'));
  });
});

chain.extend.attach(function (error, frames) {
  const lastTrace = traces.get(asyncHook.executionAsyncId());
  frames.push.apply(frames, lastTrace);
  return frames;
});

//
// Track handle objects
//
const hooks = asyncHook.createHook({
  init: asyncInit,
  before: asyncBefore,
  after: asyncAfter,
  destroy: asyncDestroy
});
hooks.enable();

stack-chain

API for combining call site modifiers

MIT
Latest version published 7 years ago

Package Health Score

65 / 100
Full package analysis