code-frame
Minimal Code Frame like babel-code-frame, but smaller
Last updated 4 years ago by hhsnopek .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install code-frame 
SYNC missed versions from official npm registry.

Code Frame npm tests coverage

Minimal Code Frame like babel-code-frame, but smaller

Install

npm install --save code-frame

Usage

const framer = require('code-frame')

// framer('...', OffendingLine, OffendingColumn, {
//   frameSize: 3,
//   tabSize: 2
// })

// Opts:
//   'frameSize': (default: 3)
//       This is calcuation is Line - Surrounding.
//       If you provide, 3, it will capture a total of two surrounding lines.
//           2 | function (foo) {
//         > 3 |   console.log(foo
//             |                  ^
//
//       The frame is formed from bottom to top. ex: 4 = ((3 - 1) / 2) gives us 1
//       line on top and bottom. If you provide an even number, 4, you'd result in
//       2 lines above and one below.
//           2 | var bar = function (foo) {
//         > 3 |   console.log(foo
//             |                  ^
//           4 |   foo = foo ? foo : 'baz'
//
//       Inorder to get the opposite result you'd inverse the frameSize, -4
//           1 | // function bar
//           2 | var bar = function (foo) {
//         > 3 |   console.log(foo
//             |                  ^
//
//       Caveats:
//         frame cuts off if the wrapping lines hit EOF/Start of File. If the
//         frameSize is 3 and the error is on line 1:
//           > 1 | 'use strict;
//               |            ^
//
//   'tabSize': (default: 2)
//     If mixed tabs are found on anylines while constructing the frame, we
//     convert them over to spaces. You may define a positive integer.

License

MIT © Henry Snopek

Current Tags

  • 5.0.0                                ...           latest (4 years ago)

6 Versions

  • 5.0.0                                ...           4 years ago
  • 4.0.0                                ...           4 years ago
  • 3.0.0                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 1
Last Week 1
Last Month 3
Dependencies (1)
Dev Dependencies (5)

Copyright 2014 - 2017 © taobao.org |