2.3.10 • Published 5 months ago

@guanghechen/parse-lineno v2.3.10

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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

Install

  • npm

    npm install --save-dev @guanghechen/parse-lineno
  • yarn

    yarn add --dev @guanghechen/parse-lineno

Usage

  • Parse lineno string into numbers.

    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.

    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]+/)

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

7 months ago

2.3.7

8 months ago

2.3.9

6 months ago

2.3.2

10 months ago

2.3.4

9 months ago

2.3.3

10 months ago

2.3.6

9 months ago

2.3.5

9 months ago

2.3.10

5 months ago

2.3.0

12 months ago

2.3.1

11 months ago

2.2.7

1 year ago

2.2.6

1 year ago

2.2.5

1 year ago

2.2.4

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

2.2.3

1 year ago

2.2.2

1 year ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.0.0-alpha.3

2 years ago

2.0.0-alpha.2

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

2.0.0-alpha.0

2 years ago

2.0.0-alpha.1

2 years ago

1.9.8

2 years ago

1.9.7

2 years ago

1.9.6

2 years ago

1.9.5

2 years ago

1.9.0-alpha.0

2 years ago

1.9.1

2 years ago

1.9.0

2 years ago

1.8.6

2 years ago

1.9.4

2 years ago

1.9.3

2 years ago

1.9.2

2 years ago

1.8.5

2 years ago

1.8.4

3 years ago

1.8.3

3 years ago

1.8.2

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.1

3 years ago

1.7.0-alpha.0

3 years ago

1.7.0

3 years ago

1.7.0-alpha.3

3 years ago

1.7.0-alpha.1

3 years ago

1.7.0-alpha.2

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.5

3 years ago

1.5.4

3 years ago