pinpoint
Display an arrow in a string of code to point to a location
Last updated 13 years ago by curvedmark .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install pinpoint 
SYNC missed versions from official npm registry.

pinpoint

Add line numbers and an arrow to a string of code that points to a specific location.

Installation

npm install pinpoint

Example

With this code:

function add(left, right) {
  return left + right;
}

console.log(add(1 + 1));

When being asked to point to line 2 and column 2, generates this:

1| function add(left, right) {
2|   return left + right;
-----^
3| }
4|
5| console.log(add(1 + 1));

API

var pinpoint = require('pinpoint');

var str = pinpoint(code, options);
  • code - a string of code
  • options - an object literal supports these options:
    • line - the line number to point to, 1-based.
    • column - the column number to point to, 1-based.
    • showLines - the number of lines to show. The pointed line will try to stay in the middle of the displays lines.
    • indent - indent string prepend to each line, before the line number.
    • tabSize - width of a tab character.

Current Tags

  • 1.1.0                                ...           latest (13 years ago)

2 Versions

  • 1.1.0                                ...           13 years ago
  • 1.0.0                                ...           13 years ago
Maintainers (1)
Downloads
Total 10
Today 0
This Week 0
This Month 10
Last Day 0
Last Week 4
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE