🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

annotate-code

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

annotate-code

beautifully annotate source code with a message, given an index, like a parser or compiler

2.0.2
Source
npm
Version published
Weekly downloads
10
900%
Maintainers
1
Weekly downloads
 
Created
Source

annotate-code

beautifully annotate source code with a message, given an index, like a parser or compiler

🔧 Install · 🧩 Example · 📜 API docs · 🔥 Releases · 💪🏼 Contribute · 🖐️ Help

Install

$ npm i annotate-code

Example

import { annotate } from 'annotate-code'

console.log(
  annotate({
    message: 'some error message',
    index: 48,
    size: 6,
    input,
  }).message
)

API

Table of Contents

annotate

src/index.ts:44-155

Annotates a source code string given an index and a message.

Parameters

  • settings {message: string, input: string, index: number, linesBefore: number?, linesAfter: number?, size: number?, showLineNumbers: boolean?}

    • settings.message The message to display
    • settings.input The code to annotate
    • settings.index The index position
    • settings.linesBefore How many lines before to show (optional, default 3)
    • settings.linesAfter How many lines after to show (optional, default 3)
    • settings.size The size of the arrows ^^^^ (optional, default 1)
    • settings.showLineNumbers Whether to show line numbers (optional, default true)

Returns {line: number?, col: number?, message: string}

Contribute

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2021 stagas

Keywords

annotate

FAQs

Package last updated on 18 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts