line-column-path
Advanced tools
Comparing version 2.0.0 to 3.0.0
@@ -29,3 +29,3 @@ import {Mutable} from 'type-fest'; | ||
*/ | ||
column?: boolean; | ||
readonly column?: boolean; | ||
} | ||
@@ -36,13 +36,13 @@ | ||
@param path - File path to parse. Can also be an object that you want to validate and normalize. | ||
@param path - The file path to parse. Can also be an object that you want to validate and normalize. | ||
@example | ||
``` | ||
import lineColumnPath = require('line-column-path'); | ||
import {parseLineColumnPath} from 'line-column-path'; | ||
lineColumnPath.parse('unicorn.js:8:14'); | ||
parseLineColumnPath('unicorn.js:8:14'); | ||
//=> {file: 'unicorn.js', line: 8, column: 14} | ||
``` | ||
*/ | ||
export function parse(path: PathLike): ParsedPath; | ||
export function parseLineColumnPath(path: PathLike): ParsedPath; | ||
@@ -54,11 +54,11 @@ /** | ||
``` | ||
import lineColumnPath = require('line-column-path'); | ||
import {stringifyLineColumnPath} from 'line-column-path'; | ||
lineColumnPath.stringify({file: 'unicorn.js', line: 8, column: 14}); | ||
stringifyLineColumnPath({file: 'unicorn.js', line: 8, column: 14}); | ||
//=> 'unicorn.js:8:14' | ||
``` | ||
*/ | ||
export function stringify( | ||
export function stringifyLineColumnPath( | ||
path: PathDescriptor, | ||
options?: StringifyOptions | ||
): string; |
21
index.js
@@ -1,4 +0,2 @@ | ||
'use strict'; | ||
exports.parse = path => { | ||
export function parseLineColumnPath(path) { | ||
if (typeof path === 'object') { | ||
@@ -12,3 +10,3 @@ if (!path.file) { | ||
line: path.line || 1, | ||
column: path.column || 1 | ||
column: path.column || 1, | ||
}; | ||
@@ -23,3 +21,3 @@ } | ||
line: 1, | ||
column: 1 | ||
column: 1, | ||
}; | ||
@@ -34,12 +32,12 @@ } | ||
file: match[1], | ||
line: Number(match[2]), | ||
column: Number(match[3]) || 1 | ||
line: Number.parseInt(match[2], 10), | ||
column: Number.parseInt(match[3], 10) || 1, | ||
}; | ||
}; | ||
} | ||
exports.stringify = (path, options) => { | ||
export function stringifyLineColumnPath(path, options) { | ||
options = { | ||
file: true, | ||
column: true, | ||
...options | ||
...options, | ||
}; | ||
@@ -70,3 +68,2 @@ | ||
return result; | ||
}; | ||
} |
{ | ||
"name": "line-column-path", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "Parse and stringify file paths with line and column like `unicorn.js:8:14`", | ||
"license": "MIT", | ||
"repository": "sindresorhus/line-column-path", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
@@ -38,9 +41,9 @@ "scripts": { | ||
"dependencies": { | ||
"type-fest": "^0.4.1" | ||
"type-fest": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
"ava": "^3.15.0", | ||
"tsd": "^0.17.0", | ||
"xo": "^0.44.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# line-column-path [![Build Status](https://travis-ci.org/sindresorhus/line-column-path.svg?branch=master)](https://travis-ci.org/sindresorhus/line-column-path) | ||
# line-column-path | ||
@@ -16,25 +16,24 @@ > Parse and stringify file paths with line and column like `unicorn.js:8:14` | ||
```js | ||
const lineColumnPath = require('line-column-path'); | ||
import {parseLineColumnPath, stringifyLineColumnPath} from 'line-column-path'; | ||
const parsed = lineColumnPath.parse('unicorn.js:8:14'); | ||
const parsed = parseLineColumnPath('unicorn.js:8:14'); | ||
//=> {file: 'unicorn.js', line: 8, column: 14} | ||
lineColumnPath.stringify(parsed); | ||
stringifyLineColumnPath(parsed); | ||
//=> 'unicorn.js:8:14' | ||
``` | ||
## API | ||
### .parse(input) | ||
### parseLineColumnPath(path) | ||
#### input | ||
#### path | ||
Type: `string | object` | ||
File path to parse. | ||
The file path to parse. | ||
Can also be an object that you want to validate and normalize. | ||
### .stringify(path, [options]) | ||
### stringifyLineColumnPath(path, options?) | ||
@@ -53,3 +52,3 @@ #### path | ||
Type: `boolean`<br> | ||
Type: `boolean`\ | ||
Default: `true` | ||
@@ -63,3 +62,3 @@ | ||
Type: `boolean`<br> | ||
Type: `boolean`\ | ||
Default: `true` | ||
@@ -70,6 +69,1 @@ | ||
Setting this to `false` will result in `unicorn.js:8` instead of `unicorn.js:8:14`. | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Sorry, the diff of this file is not supported yet
5420
Yes
98
66
+ Addedtype-fest@2.19.0(transitive)
- Removedtype-fest@0.4.1(transitive)
Updatedtype-fest@^2.0.0