Cleaner and more readable stack traces for all

npm install stack-filter
143 downloads in the last day
716 downloads in the last week
5 090 downloads in the last month



Cleaner and more readable stack traces for all

.. raw:: html

<a href="" class="travis">
  <img src="">

stack-filter is a tiny module that strips out unwanted elements of a stack trace and optimizing the remaining items for readability. stack-filter works in browsers (including old and rowdy ones, like IE6) and Node. It will define itself as an AMD module if you want it to (i.e. if there's a define function available).


stackFilter(stackTrace[, cwd])

Accepts a stack trace as a string (e.g. one obtained from ``error.stack``) and
an optional working directory, and returns a pruned stack trace in the form of
an array of lines.

The ``cwd`` option is used to shorten paths by removing common prefixes. For
example, Buster.JS uses this option to trim down URLs like
to ``lib/files.js``. The current working directory is optional, and may be
either a string or a regular expression.


    var stackFilter = require("stack-filter");

    stackFilter.filters.push("jquery.js"); // Ignore lines from within jQuery
    stackFilter(error.stack); //=> Lines, excluding any lines from within jQuery


This array contains all the filters. A filter may be either a string (partial match against path) or a regular expression.

npm loves you