Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. # stack-utils
  2. > Captures and cleans stack traces.
  3. [![Linux Build](https://travis-ci.org/tapjs/stack-utils.svg?branch=master)](https://travis-ci.org/tapjs/stack-utils) [![Build status](https://ci.appveyor.com/api/projects/status/fb9i157knoixe3iq/branch/master?svg=true)](https://ci.appveyor.com/project/jamestalmage/stack-utils-oiw96/branch/master) [![Coverage](https://coveralls.io/repos/tapjs/stack-utils/badge.svg?branch=master&service=github)](https://coveralls.io/github/tapjs/stack-utils?branch=master)
  4. Extracted from `lib/stack.js` in the [`node-tap` project](https://github.com/tapjs/node-tap)
  5. ## Install
  6. ```
  7. $ npm install --save stack-utils
  8. ```
  9. ## Usage
  10. ```js
  11. const StackUtils = require('stack-utils');
  12. const stack = new StackUtils({cwd: process.cwd(), internals: StackUtils.nodeInternals()});
  13. console.log(stack.clean(new Error().stack));
  14. // outputs a beautified stack trace
  15. ```
  16. ## API
  17. ### new StackUtils([options])
  18. Creates a new `stackUtils` instance.
  19. #### options
  20. ##### internals
  21. Type: `array` of `RegularExpression`s
  22. A set of regular expressions that match internal stack stack trace lines which should be culled from the stack trace.
  23. The default is `StackUtils.nodeInternals()`, this can be disabled by setting `[]` or appended using
  24. `StackUtils.nodeInternals().concat(additionalRegExp)`. See also `ignoredPackages`.
  25. ##### ignoredPackages
  26. Type: `array` of `string`s
  27. An array of npm modules to be culled from the stack trace. This list will mapped to regular
  28. expressions and merged with the `internals`.
  29. Default `''`.
  30. ##### cwd
  31. Type: `string`
  32. The path to the current working directory. File names in the stack trace will be shown relative to this directory.
  33. ##### wrapCallSite
  34. Type: `function(CallSite)`
  35. A mapping function for manipulating CallSites before processing. The first argument is a CallSite instance, and the function should return a modified CallSite. This is useful for providing source map support.
  36. ### StackUtils.nodeInternals()
  37. Returns an array of regular expressions that be used to cull lines from the stack trace that reference common Node.js internal files.
  38. ### stackUtils.clean(stack, indent = 0)
  39. Cleans up a stack trace by deleting any lines that match the `internals` passed to the constructor, and shortening file names relative to `cwd`.
  40. Returns a `string` with the cleaned up stack (always terminated with a `\n` newline character).
  41. Spaces at the start of each line are trimmed, indentation can be added by setting `indent` to the desired number of spaces.
  42. #### stack
  43. *Required*
  44. Type: `string` or an `array` of `string`s
  45. ### stackUtils.capture([limit], [startStackFunction])
  46. Captures the current stack trace, returning an array of `CallSite`s. There are good overviews of the available CallSite methods [here](https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces), and [here](https://github.com/sindresorhus/callsites#api).
  47. #### limit
  48. Type: `number`
  49. Default: `Infinity`
  50. Limits the number of lines returned by dropping all lines in excess of the limit. This removes lines from the stack trace.
  51. #### startStackFunction
  52. Type: `function`
  53. The function where the stack trace should start. The first line of the stack trace will be the function that called `startStackFunction`. This removes lines from the end of the stack trace.
  54. ### stackUtils.captureString([limit], [startStackFunction])
  55. Captures the current stack trace, cleans it using `stackUtils.clean(stack)`, and returns a string with the cleaned stack trace. It takes the same arguments as `stackUtils.capture`.
  56. ### stackUtils.at([startStackFunction])
  57. Captures the first line of the stack trace (or the first line after `startStackFunction` if supplied), and returns a `CallSite` like object that is serialization friendly (properties are actual values instead of getter functions).
  58. The available properties are:
  59. - `line`: `number`
  60. - `column`: `number`
  61. - `file`: `string`
  62. - `constructor`: `boolean`
  63. - `evalOrigin`: `string`
  64. - `native`: `boolean`
  65. - `type`: `string`
  66. - `function`: `string`
  67. - `method`: `string`
  68. ### stackUtils.parseLine(line)
  69. Parses a `string` (which should be a single line from a stack trace), and generates an object with the following properties:
  70. - `line`: `number`
  71. - `column`: `number`
  72. - `file`: `string`
  73. - `constructor`: `boolean`
  74. - `evalOrigin`: `string`
  75. - `evalLine`: `number`
  76. - `evalColumn`: `number`
  77. - `evalFile`: `string`
  78. - `native`: `boolean`
  79. - `function`: `string`
  80. - `method`: `string`
  81. ## License
  82. MIT © [Isaac Z. Schlueter](http://github.com/isaacs), [James Talmage](http://github.com/jamestalmage)