National Preventative Mechanism
    Wondering what’s next for npm?Check out our public roadmap! »

    @distributed-systems/stack-trace

    2.0.0 • Public • Published

    Callsite

    Get clean, standardized stack traces from V8 Error objects

    ESM:

    import StackTrace from 'es-modules/distributed-systems/stack-trace/1.0.0+/index.mjs';

    NPM:

    import StackTrace from '@distributed-systems/stack-trace';
     

    API

    Stack Frame format returned from the library

    [{
        name: 'new Cls',
        source: 'stack-trace/test/200.000-stack-parser.mjs',
        line: 52,
        column: 27 
    }, {
        name: null,
        source: 'stack-trace/test/200.000-stack-parser.mjs',
        line: 56,
        column: 13 
    }, {
        name: 'section.test',
        source: 'stack-trace/test/200.000-stack-parser.mjs',
        line: 57,
        column: 11 
    }, {
        name: 'Promise',
        source: 'section-tests/src/SectionExecutor.mjs',
        line: 162,
        column: 41 
    }, { 
        name: 'new Promise', 
        source: null, 
        line: null, 
        column: null 
    },{
        name: 'SectionExecutor.executeTests',
        source: 'section-tests/src/SectionExecutor.mjs',
        line: 157,
        column: 23 
    }]
     

    Get a Stack-Trace

    const st = new StackTrace();
    const err = new Error('I want a structured stack trace!');
     
    // gets a structured stack from the error passed in
    const trace = st.getStack(err); 
     

    Get a Stack-Trace with a base directory removed from the file paths

    const st = new StackTrace();
    const err = new Error('I want a structured stack trace!');
     
    // if a frame has a file in the directory defined in the variable below, 
    // the portion defined here will be removed from its path 
    const baseDir = '/home/ee';
     
    // gets a structured stack from the error passed in
    const trace = st.getStack(err, baseDir); 
     

    TBD: node 12 can be used with --async-stack-traces

    Install

    npm i @distributed-systems/stack-trace

    DownloadsWeekly Downloads

    1

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    25.2 kB

    Total Files

    13

    Last publish

    Collaborators

    • avatar