vfile-location
Advanced tools
Comparing version 2.0.1 to 2.0.2
66
index.js
@@ -1,10 +0,1 @@ | ||
/** | ||
* @author Titus Wormer | ||
* @copyright 2016 Titus Wormer | ||
* @license MIT | ||
* @module vfile-location | ||
* @fileoverview Convert between positions (line and column-based) | ||
* and offsets (range-based) locations in a virtual file. | ||
*/ | ||
'use strict'; | ||
@@ -15,7 +6,3 @@ | ||
/** | ||
* Factory. | ||
* | ||
* @param {VFile|string|Buffer} file - Virtual file or document. | ||
*/ | ||
/* Factory. */ | ||
function factory(file) { | ||
@@ -30,23 +17,9 @@ var contents = indices(String(file)); | ||
/** | ||
* Factory to get the line and column-based `position` for | ||
* `offset` in the bound indices. | ||
* | ||
* @param {Array.<number>} indices - Indices of | ||
* line-breaks in `value`. | ||
* @return {Function} - Bound method. | ||
*/ | ||
/* Factory to get the line and column-based `position` for | ||
* `offset` in the bound indices. */ | ||
function offsetToPositionFactory(indices) { | ||
return offsetToPosition; | ||
/** | ||
* Get the line and column-based `position` for | ||
* `offset` in the bound indices. | ||
* | ||
* @param {number} offset - Offset. | ||
* @return {Position} - Object with `line`, `column`, | ||
* and `offset` properties based on the bound | ||
* `indices`. An empty object when given invalid | ||
* or out of bounds input. | ||
*/ | ||
/* Get the line and column-based `position` for | ||
* `offset` in the bound indices. */ | ||
function offsetToPosition(offset) { | ||
@@ -74,22 +47,9 @@ var index = -1; | ||
/** | ||
* Factory to get the `offset` for a line and column-based | ||
* `position` in the bound indices. | ||
* | ||
* @param {Array.<number>} indices - Indices of | ||
* line-breaks in `value`. | ||
* @return {Function} - Bound method. | ||
*/ | ||
/* Factory to get the `offset` for a line and column-based | ||
* `position` in the bound indices. */ | ||
function positionToOffsetFactory(indices) { | ||
return positionToOffset; | ||
/** | ||
* Get the `offset` for a line and column-based | ||
* `position` in the bound indices. | ||
* | ||
* @param {Position} position - Object with `line` and | ||
* `column` properties. | ||
* @return {number} - Offset. `-1` when given invalid | ||
* or out of bounds input. | ||
*/ | ||
/* Get the `offset` for a line and column-based | ||
* `position` in the bound indices. */ | ||
function positionToOffset(position) { | ||
@@ -107,9 +67,3 @@ var line = position && position.line; | ||
/** | ||
* Get indices of line-breaks in `value`. | ||
* | ||
* @param {string} value - Value. | ||
* @return {Array.<number>} - List of indices of | ||
* line-breaks. | ||
*/ | ||
/* Get indices of line-breaks in `value`. */ | ||
function indices(value) { | ||
@@ -116,0 +70,0 @@ var result = []; |
{ | ||
"name": "vfile-location", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Convert between positions (line and column-based) and offsets (range-based) locations in a virtual file", | ||
@@ -13,4 +13,4 @@ "license": "MIT", | ||
], | ||
"repository": "https://github.com/wooorm/vfile-location", | ||
"bugs": "https://github.com/wooorm/vfile-location/issues", | ||
"repository": "https://github.com/vfile/vfile-location", | ||
"bugs": "https://github.com/vfile/vfile-location/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
@@ -25,16 +25,13 @@ "contributors": [ | ||
"devDependencies": { | ||
"browserify": "^13.0.1", | ||
"browserify": "^14.0.0", | ||
"esmangle": "^1.0.1", | ||
"nyc": "^8.1.0", | ||
"remark-cli": "^1.0.0", | ||
"remark-comment-config": "^4.0.0", | ||
"remark-github": "^5.0.0", | ||
"remark-lint": "^4.0.0", | ||
"remark-validate-links": "^4.0.0", | ||
"nyc": "^11.0.0", | ||
"remark-cli": "^3.0.0", | ||
"remark-preset-wooorm": "^3.0.0", | ||
"tape": "^4.0.0", | ||
"vfile": "^2.0.0", | ||
"xo": "^0.16.0" | ||
"xo": "^0.18.0" | ||
}, | ||
"scripts": { | ||
"build-md": "remark . --quiet --frail", | ||
"build-md": "remark . -qfo", | ||
"build-bundle": "browserify index.js --bare -s vfileLocation > vfile-location.js", | ||
@@ -56,2 +53,3 @@ "build-mangle": "esmangle vfile-location.js > vfile-location.min.js", | ||
"space": true, | ||
"esnext": false, | ||
"ignores": [ | ||
@@ -62,13 +60,6 @@ "vfile-location.js" | ||
"remarkConfig": { | ||
"output": true, | ||
"plugins": { | ||
"comment-config": null, | ||
"github": null, | ||
"lint": null, | ||
"validate-links": null | ||
}, | ||
"settings": { | ||
"bullet": "*" | ||
} | ||
"plugins": [ | ||
"preset-wooorm" | ||
] | ||
} | ||
} |
@@ -8,3 +8,3 @@ # vfile-location [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
[npm][npm-install]: | ||
[npm][]: | ||
@@ -22,17 +22,6 @@ ```bash | ||
var offset = location.toOffset({line: 3, column: 3}); | ||
var position = location.toPosition(offset); | ||
location.toOffset({line: 3, column: 3}); //=> 10 | ||
location.toPosition(offset); //=> {line: 3, column: 3, offset: 10} | ||
``` | ||
Yields: | ||
```js | ||
10 | ||
{ | ||
"line": 3, | ||
"column": 3, | ||
"offset": 10 | ||
} | ||
``` | ||
## API | ||
@@ -65,11 +54,11 @@ | ||
[travis-badge]: https://img.shields.io/travis/wooorm/vfile-location.svg | ||
[travis-badge]: https://img.shields.io/travis/vfile/vfile-location.svg | ||
[travis]: https://travis-ci.org/wooorm/vfile-location | ||
[travis]: https://travis-ci.org/vfile/vfile-location | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/vfile-location.svg | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/vfile/vfile-location.svg | ||
[codecov]: https://codecov.io/github/wooorm/vfile-location | ||
[codecov]: https://codecov.io/github/vfile/vfile-location | ||
[npm-install]: https://docs.npmjs.com/cli/install | ||
[npm]: https://docs.npmjs.com/cli/install | ||
@@ -80,3 +69,3 @@ [license]: LICENSE | ||
[vfile]: https://github.com/wooorm/vfile | ||
[vfile]: https://github.com/vfile/vfile | ||
@@ -87,2 +76,2 @@ [to-offset]: #locationtooffsetposition | ||
[position]: https://github.com/wooorm/unist#position | ||
[position]: https://github.com/syntax-tree/unist#position |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
8
6109
61
73