# @guanghechen/parse-lineno

> Parse something like '1,3-10' to numbers or intervals

Latest version **2.3.10** (published 2023-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @guanghechen/parse-lineno
pnpm add @guanghechen/parse-lineno
yarn add @guanghechen/parse-lineno
bun add @guanghechen/parse-lineno
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.3.10 |
| Published | 2023-11-29 |
| First published | 2021-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | guanghechen |
| Maintainers | lemonclown |
| Keywords | lineno string, interval string |

## Links

- npm: https://www.npmjs.com/package/@guanghechen/parse-lineno
- Repository: https://github.com/guanghechen/react-kit.git#@guanghechen
- Homepage: https://github.com/guanghechen/react-kit/tree/@guanghechen/parse-lineno@2.3.9/packages/parse-lineno#readme
- Issues: https://github.com/guanghechen/react-kit/issues
- npm.io page: https://npm.io/package/@guanghechen/parse-lineno

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 2.3.10 (latest) — 2023-11-29
- 2.3.9 — 2023-11-26
- 2.3.8 — 2023-10-04
- 2.3.7 — 2023-09-04
- 2.3.6 — 2023-08-30
- 2.3.5 — 2023-08-16
- 2.3.4 — 2023-08-07
- 2.3.3 — 2023-07-29
- 2.3.2 — 2023-07-15
- 2.3.1 — 2023-06-18
- 2.3.0 — 2023-05-13
- 2.2.7 — 2023-04-02
- 2.2.6 — 2023-04-02
- 2.2.5 — 2023-03-11
- 2.2.4 — 2023-02-03
- … 41 more at https://npm.io/package/@guanghechen/parse-lineno/versions

## README

<header>
  <h1 align="center">
    <a href="https://github.com/guanghechen/react-kit/tree/@guanghechen/parse-lineno@2.3.10/packages/parse-lineno#readme">@guanghechen/parse-lineno</a>
  </h1>
  <div align="center">
    <a href="https://www.npmjs.com/package/@guanghechen/parse-lineno">
      <img
        alt="Npm Version"
        src="https://img.shields.io/npm/v/@guanghechen/parse-lineno.svg"
      />
    </a>
    <a href="https://www.npmjs.com/package/@guanghechen/parse-lineno">
      <img
        alt="Npm Download"
        src="https://img.shields.io/npm/dm/@guanghechen/parse-lineno.svg"
      />
    </a>
    <a href="https://www.npmjs.com/package/@guanghechen/parse-lineno">
      <img
        alt="Npm License"
        src="https://img.shields.io/npm/l/@guanghechen/parse-lineno.svg"
      />
    </a>
    <a href="#install">
      <img
        alt="Module Formats: cjs, esm"
        src="https://img.shields.io/badge/module_formats-cjs%2C%20esm-green.svg"
      />
    </a>
    <a href="https://github.com/nodejs/node">
      <img
        alt="Node.js Version"
        src="https://img.shields.io/node/v/@guanghechen/parse-lineno"
      />
    </a>
    <a href="https://github.com/facebook/jest">
      <img
        alt="Tested with Jest"
        src="https://img.shields.io/badge/tested_with-jest-9c465e.svg"
      />
    </a>
    <a href="https://github.com/prettier/prettier">
      <img
        alt="Code Style: prettier"
        src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"
      />
    </a>
  </div>
</header>
<br/>


Parse something like '1,3-10' to numbers or intervals.

## Install

* npm

  ```bash
  npm install --save-dev @guanghechen/parse-lineno
  ```

* yarn

  ```bash
  yarn add --dev @guanghechen/parse-lineno
  ```

## Usage

* Parse lineno string into numbers.

  ```typescript
  import { collectNumbers } from '@guanghechen/parse-lineno'

  collectNumbers('')              // => []
  collectNumbers('1')             // => [1]
  collectNumbers('1-3')           // => [1, 2, 3]
  collectNumbers('3,1-2,2,2')     // => [1, 2, 3]
  collectNumbers('3,7-5,2,2')     // => [2, 3, 5, 6, 7]
  collectNumbers('2,1-3')         // => [1, 2, 3]
  collectNumbers('4,1-3')         // => [1, 2, 3, 4]
  collectNumbers('2-4,1-3,5-9')   // => [1, 2, 3, 4, 5, 6, 7, 8, 9]
  collectNumbers('2-4,1-3,6-9')   // => [1, 2, 3, 4, 6, 7, 8, 9]
  ```

* Parse lineno string into intervals.

  ```typescript
  import { collectIntervals } from '@guanghechen/parse-lineno'

  collectIntervals('')              // => []
  collectIntervals('1')             // => [[1, 1]]
  collectIntervals('1-3')           // => [[1, 3]]
  collectIntervals('3,1-2,2,2')     // => [[1, 3]]
  collectIntervals('3,7-5,2,2')     // => [[2, 3], [5, 7]]
  collectIntervals('2,1-3')         // => [[1, 3]]
  collectIntervals('4,1-3')         // => [[1, 4]]
  collectIntervals('2-4,1-3,5-9')   // => [[1, 9]]
  collectIntervals('2-4,1-3,6-9')   // => [[1, 4], [6, 9]]
  ```

* Custom Separator (default is `/[,\s]+/`)

  ```typescript
  collectNumbers('2#4-5#5-8', /#/)    // => [2, 4, 5, 6, 7, 8]

  collectIntervals('2#4-5#5-8', /#/)  // => [[2, 2], [4, 8]]
  ```

[homepage]: https://github.com/guanghechen/react-kit/tree/@guanghechen/parse-lineno@2.3.10/packages/parse-lineno#readme

---
_Source: https://npm.io/package/@guanghechen/parse-lineno · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
