lines-and-columns

中文文档
2.0.4发布于 2023/11/07MITTypeScriptESM + CJS零依赖近 30 天下载 5亿

Maps lines and columns to character offsets and back.

原始使用文档
文档目录3 节
  1. Install
  2. Usage
  3. License

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

版本与发布记录

lines-and-columns 共发布 25 个版本,首次发布于 2015/12/03;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.4latest2023/11/072 年前
2.0.32021/11/234 年前
1.2.4v12x2021/11/214 年前
1.1.11v11x2021/11/214 年前
1.1.102021/11/214 年前
1.2.32021/11/214 年前

关于 lines-and-columns 的常见问题

lines-and-columns 是什么?

Maps lines and columns to character offsets and back.

如何安装 lines-and-columns?

在项目目录运行 npm install lines-and-columns,或使用 pnpm add / yarn add / bun add。

lines-and-columns 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

lines-and-columns 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

lines-and-columns 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^12.20.0 || ^14.13.1 || >=16.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

lines-and-columns 可以商用吗?

lines-and-columns 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

lines-and-columns 的下载量有多少?

根据 npm 官方下载统计,lines-and-columns 在 2026/10/05 – 2026/11/03 这 30 天内被下载 501,530,836 次,日均约 16,717,695 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

lines-and-columns 还在维护吗?

最新版本 2.0.4 发布于 2023/11/07(2 年前);至今共发布 25 个版本,其中过去 12 个月发布了 0 个;首次发布于 2015/12/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。