summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/vfile-location
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/vfile-location')
-rw-r--r--tools/node_modules/eslint/node_modules/vfile-location/LICENSE22
-rw-r--r--tools/node_modules/eslint/node_modules/vfile-location/index.js77
-rw-r--r--tools/node_modules/eslint/node_modules/vfile-location/package.json100
-rw-r--r--tools/node_modules/eslint/node_modules/vfile-location/readme.md72
4 files changed, 271 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/vfile-location/LICENSE b/tools/node_modules/eslint/node_modules/vfile-location/LICENSE
new file mode 100644
index 0000000000..8d8660d36e
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/vfile-location/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/tools/node_modules/eslint/node_modules/vfile-location/index.js b/tools/node_modules/eslint/node_modules/vfile-location/index.js
new file mode 100644
index 0000000000..9263d2486a
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/vfile-location/index.js
@@ -0,0 +1,77 @@
+'use strict';
+
+/* Expose. */
+module.exports = factory;
+
+/* Factory. */
+function factory(file) {
+ var contents = indices(String(file));
+
+ return {
+ toPosition: offsetToPositionFactory(contents),
+ toOffset: positionToOffsetFactory(contents)
+ };
+}
+
+/* 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. */
+ function offsetToPosition(offset) {
+ var index = -1;
+ var length = indices.length;
+
+ if (offset < 0) {
+ return {};
+ }
+
+ while (++index < length) {
+ if (indices[index] > offset) {
+ return {
+ line: index + 1,
+ column: (offset - (indices[index - 1] || 0)) + 1,
+ offset: offset
+ };
+ }
+ }
+
+ return {};
+ }
+}
+
+/* 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. */
+ function positionToOffset(position) {
+ var line = position && position.line;
+ var column = position && position.column;
+
+ if (!isNaN(line) && !isNaN(column) && line - 1 in indices) {
+ return ((indices[line - 2] || 0) + column - 1) || 0;
+ }
+
+ return -1;
+ }
+}
+
+/* Get indices of line-breaks in `value`. */
+function indices(value) {
+ var result = [];
+ var index = value.indexOf('\n');
+
+ while (index !== -1) {
+ result.push(index + 1);
+ index = value.indexOf('\n', index + 1);
+ }
+
+ result.push(value.length + 1);
+
+ return result;
+}
diff --git a/tools/node_modules/eslint/node_modules/vfile-location/package.json b/tools/node_modules/eslint/node_modules/vfile-location/package.json
new file mode 100644
index 0000000000..923b71f7bd
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/vfile-location/package.json
@@ -0,0 +1,100 @@
+{
+ "_from": "vfile-location@^2.0.0",
+ "_id": "vfile-location@2.0.2",
+ "_inBundle": false,
+ "_integrity": "sha1-02dcWch3SY5JK0dW/2Xkrxp1IlU=",
+ "_location": "/vfile-location",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "vfile-location@^2.0.0",
+ "name": "vfile-location",
+ "escapedName": "vfile-location",
+ "rawSpec": "^2.0.0",
+ "saveSpec": null,
+ "fetchSpec": "^2.0.0"
+ },
+ "_requiredBy": [
+ "/remark-parse"
+ ],
+ "_resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-2.0.2.tgz",
+ "_shasum": "d3675c59c877498e492b4756ff65e4af1a752255",
+ "_spec": "vfile-location@^2.0.0",
+ "_where": "/Users/cjihrig/iojs/node/tools/eslint-tmp/node_modules/eslint/node_modules/remark-parse",
+ "author": {
+ "name": "Titus Wormer",
+ "email": "tituswormer@gmail.com",
+ "url": "http://wooorm.com"
+ },
+ "bugs": {
+ "url": "https://github.com/vfile/vfile-location/issues"
+ },
+ "bundleDependencies": false,
+ "contributors": [
+ {
+ "name": "Titus Wormer",
+ "email": "tituswormer@gmail.com",
+ "url": "http://wooorm.com"
+ }
+ ],
+ "dependencies": {},
+ "deprecated": false,
+ "description": "Convert between positions (line and column-based) and offsets (range-based) locations in a virtual file",
+ "devDependencies": {
+ "browserify": "^14.0.0",
+ "esmangle": "^1.0.1",
+ "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.18.0"
+ },
+ "files": [
+ "index.js"
+ ],
+ "homepage": "https://github.com/vfile/vfile-location#readme",
+ "keywords": [
+ "remark",
+ "comment",
+ "message",
+ "marker",
+ "control"
+ ],
+ "license": "MIT",
+ "name": "vfile-location",
+ "nyc": {
+ "check-coverage": true,
+ "lines": 100,
+ "functions": 100,
+ "branches": 100
+ },
+ "remarkConfig": {
+ "plugins": [
+ "preset-wooorm"
+ ]
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/vfile/vfile-location.git"
+ },
+ "scripts": {
+ "build": "npm run build-md && npm run build-bundle && npm run build-mangle",
+ "build-bundle": "browserify index.js --bare -s vfileLocation > vfile-location.js",
+ "build-mangle": "esmangle vfile-location.js > vfile-location.min.js",
+ "build-md": "remark . -qfo",
+ "lint": "xo",
+ "test": "npm run build && npm run lint && npm run test-coverage",
+ "test-api": "node test",
+ "test-coverage": "nyc --reporter lcov tape test.js"
+ },
+ "version": "2.0.2",
+ "xo": {
+ "space": true,
+ "esnext": false,
+ "ignores": [
+ "vfile-location.js"
+ ]
+ }
+}
diff --git a/tools/node_modules/eslint/node_modules/vfile-location/readme.md b/tools/node_modules/eslint/node_modules/vfile-location/readme.md
new file mode 100644
index 0000000000..c9bad64cce
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/vfile-location/readme.md
@@ -0,0 +1,72 @@
+# vfile-location [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
+
+Convert between positions (line and column-based) and offsets
+(range-based) locations in a [virtual file][vfile].
+
+## Installation
+
+[npm][]:
+
+```bash
+npm install vfile-location
+```
+
+## Usage
+
+```js
+var vfile = require('vfile');
+var vfileLocation = require('vfile-location');
+var location = vfileLocation(vfile('foo\nbar\nbaz'));
+
+location.toOffset({line: 3, column: 3}); //=> 10
+location.toPosition(offset); //=> {line: 3, column: 3, offset: 10}
+```
+
+## API
+
+### `location = vfileLocation(doc)`
+
+Get transform functions for the given `doc` (`string`) or
+[`file`][vfile].
+
+Returns an object with [`toOffset`][to-offset] and
+[`toPosition`][to-position].
+
+### `location.toOffset(position)`
+
+Get the `offset` (`number`) for a line and column-based
+[`position`][position] in the bound file. Returns `-1`
+when given invalid or out of bounds input.
+
+### `location.toPosition(offset)`
+
+Get the line and column-based [`position`][position] for `offset` in
+the bound file.
+
+## License
+
+[MIT][license] © [Titus Wormer][author]
+
+<!-- Definitions -->
+
+[travis-badge]: https://img.shields.io/travis/vfile/vfile-location.svg
+
+[travis]: https://travis-ci.org/vfile/vfile-location
+
+[codecov-badge]: https://img.shields.io/codecov/c/github/vfile/vfile-location.svg
+
+[codecov]: https://codecov.io/github/vfile/vfile-location
+
+[npm]: https://docs.npmjs.com/cli/install
+
+[license]: LICENSE
+
+[author]: http://wooorm.com
+
+[vfile]: https://github.com/vfile/vfile
+
+[to-offset]: #locationtooffsetposition
+
+[to-position]: #locationtopositionoffset
+
+[position]: https://github.com/syntax-tree/unist#position