1. lines-and-columns
Maps lines and columns to character offsets and back.
lines-and-columns
Package: lines-and-columns
Created by: eventualbuddha
Last modified: Tue, 07 Nov 2023 01:41:53 GMT
Version: 2.0.4
License: MIT
Downloads: 149,854,875
Repository: https://github.com/eventualbuddha/lines-and-columns

Install

npm install lines-and-columns
yarn add lines-and-columns

lines-and-columns

Maps lines and columns to character offsets and back. This is useful for parsers
and other text processors that deal in character ranges but process text with
meaningful lines and columns.

Install

$ npm install [--save] lines-and-columns

Usage

 import { LinesAndColumns } from 'lines-and-columns'

const lines = new LinesAndColumns(
  `table {
  border: 0
}`
)

lines.locationForIndex(9)
// { line: 1, column: 1 }

lines.indexForLocation({ line: 1, column: 2 })
// 10

License

MIT

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code