How to use the stack-chain.filter 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 DevExpress / testcafe / test / server / data / test-callsite / index.js View on Github external
var createCallsiteRecord = require('callsite-record');
var stackTrace           = require('stack-chain');

var record = null;

// NOTE: Limit stack entries to this file
function stackFilter (err, frames) {
    return frames
        .filter(function (frame) {
            var filename = frame.getFileName();

            return filename === __filename || filename === require.resolve('callsite-record');
        });
}

stackTrace.filter.attach(stackFilter);

function func1 () {
    record = createCallsiteRecord({ byFunctionName: 'func1' });
}

(function func2 () {
    func1();
})();

stackTrace.filter.deattach(stackFilter);

module.exports = record;
github AndreasMadsen / trace / trace.js View on Github external
const chain = require('stack-chain');
const asyncHook = require('async_hooks');

// Contains init asyncId of the active scope(s)
// Because we can't know when the root scope ends, a permanent Set is keept
// for the root scope.
const executionScopeInits = new Set();
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({
github trendscenter / coinstac / packages / coinstac-ui / app / main / utils / boot / configure-dev-services.js View on Github external
// Conditionally load development services if run from CLI
if (
  process.defaultApp &&
  process.env.NODE_ENV !== 'production' &&
  process.env.NODE_ENV !== 'test'
) {
  // active long stack trace
  require('trace'); // eslint-disable-line global-require
  const chain = require('stack-chain'); // eslint-disable-line global-require
  const sep = require('path').sep; // eslint-disable-line global-require

  // There is no limit for the size of the stack trace (v8 default is 10)
  Error.stackTraceLimit = Infinity;

  chain.filter.attach((error, frames) => {
    return frames.filter((callSite) => {
      const name = callSite && callSite.getFileName();
      const include = !(
        !name ||
        name.indexOf(sep) === -1 ||
        name.match(/internal\//) ||
        name.match(/tick/) ||
        name.match(/electron-preb/)
     );
      return include;
    });
  });

  /**
  * Load electron-debug, which loads devtron automatically.
  *
github DevExpress / testcafe / test / server / data / test-callsite / index.js View on Github external
return filename === __filename || filename === require.resolve('callsite-record');
        });
}

stackTrace.filter.attach(stackFilter);

function func1 () {
    record = createCallsiteRecord({ byFunctionName: 'func1' });
}

(function func2 () {
    func1();
})();

stackTrace.filter.deattach(stackFilter);

module.exports = record;
github cucumber / cucumber-js / src / stack_trace_filter.js View on Github external
filter() {
    this.currentFilter = stackChain.filter.attach((_err, frames) => {
      if (this.isErrorInCucumber(frames)) {
        return frames
      }
      const index = _.findIndex(frames, ::this.isFrameInCucumber)
      if (index === -1) {
        return frames
      }
      return frames.slice(0, index)
    })
  }
github AndreasMadsen / clarify / clarify.js View on Github external
'use strict';

const chain = require('stack-chain');
const sep = require('path').sep;

chain.filter.attach(function (error, frames) {
  return frames.filter(function (callSite) {
    const name = callSite && callSite.getFileName();
    return (name && name.includes(sep) && !name.startsWith('internal'));
  });
});
github cucumber / cucumber-js / lib / cucumber / runtime / stack_trace_filter.js View on Github external
function unfilter() {
  chain.filter.deattach(currentFilter);
}

stack-chain

API for combining call site modifiers

MIT
Latest version published 7 years ago

Package Health Score

65 / 100
Full package analysis