This commit is contained in:
50
node_modules/unist-util-stringify-position/index.js
generated
vendored
Normal file
50
node_modules/unist-util-stringify-position/index.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
'use strict'
|
||||
|
||||
var own = {}.hasOwnProperty
|
||||
|
||||
module.exports = stringify
|
||||
|
||||
function stringify(value) {
|
||||
// Nothing.
|
||||
if (!value || typeof value !== 'object') {
|
||||
return ''
|
||||
}
|
||||
|
||||
// Node.
|
||||
if (own.call(value, 'position') || own.call(value, 'type')) {
|
||||
return position(value.position)
|
||||
}
|
||||
|
||||
// Position.
|
||||
if (own.call(value, 'start') || own.call(value, 'end')) {
|
||||
return position(value)
|
||||
}
|
||||
|
||||
// Point.
|
||||
if (own.call(value, 'line') || own.call(value, 'column')) {
|
||||
return point(value)
|
||||
}
|
||||
|
||||
// ?
|
||||
return ''
|
||||
}
|
||||
|
||||
function point(point) {
|
||||
if (!point || typeof point !== 'object') {
|
||||
point = {}
|
||||
}
|
||||
|
||||
return index(point.line) + ':' + index(point.column)
|
||||
}
|
||||
|
||||
function position(pos) {
|
||||
if (!pos || typeof pos !== 'object') {
|
||||
pos = {}
|
||||
}
|
||||
|
||||
return point(pos.start) + '-' + point(pos.end)
|
||||
}
|
||||
|
||||
function index(value) {
|
||||
return value && typeof value === 'number' ? value : 1
|
||||
}
|
||||
22
node_modules/unist-util-stringify-position/license
generated
vendored
Normal file
22
node_modules/unist-util-stringify-position/license
generated
vendored
Normal file
@@ -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.
|
||||
84
node_modules/unist-util-stringify-position/package.json
generated
vendored
Normal file
84
node_modules/unist-util-stringify-position/package.json
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"name": "unist-util-stringify-position",
|
||||
"version": "2.0.3",
|
||||
"description": "unist utility to serialize a node, position, or point as a human readable location",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"unist",
|
||||
"unist-util",
|
||||
"util",
|
||||
"utility",
|
||||
"position",
|
||||
"location",
|
||||
"point",
|
||||
"node",
|
||||
"stringify",
|
||||
"tostring"
|
||||
],
|
||||
"repository": "syntax-tree/unist-util-stringify-position",
|
||||
"bugs": "https://github.com/syntax-tree/unist-util-stringify-position/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"types": "types/index.d.ts",
|
||||
"files": [
|
||||
"types/index.d.ts",
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/unist": "^2.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.0.0",
|
||||
"dtslint": "^3.0.0",
|
||||
"nyc": "^15.0.0",
|
||||
"prettier": "^1.0.0",
|
||||
"remark-cli": "^7.0.0",
|
||||
"remark-preset-wooorm": "^6.0.0",
|
||||
"tape": "^4.0.0",
|
||||
"tinyify": "^2.0.0",
|
||||
"typescript": "^3.0.0",
|
||||
"xo": "^0.27.0"
|
||||
},
|
||||
"scripts": {
|
||||
"format": "remark . -qfo && prettier --write \"**/*.{js,ts}\" && xo --fix",
|
||||
"build-bundle": "browserify . -s unistUtilStringifyPosition > unist-util-stringify-position.js",
|
||||
"build-mangle": "browserify . -s unistUtilStringifyPosition -p tinyify > unist-util-stringify-position.min.js",
|
||||
"build": "npm run build-bundle && npm run build-mangle",
|
||||
"test-api": "node test",
|
||||
"test-coverage": "nyc --reporter lcov tape test.js",
|
||||
"test-types": "dtslint types",
|
||||
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
|
||||
},
|
||||
"nyc": {
|
||||
"check-coverage": true,
|
||||
"lines": 100,
|
||||
"functions": 100,
|
||||
"branches": 100
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"esnext": false,
|
||||
"ignores": [
|
||||
"unist-util-stringify-position.js"
|
||||
]
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
}
|
||||
}
|
||||
140
node_modules/unist-util-stringify-position/readme.md
generated
vendored
Normal file
140
node_modules/unist-util-stringify-position/readme.md
generated
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
# unist-util-stringify-position
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
|
||||
[**unist**][unist] utility to pretty print the positional information of a node.
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```sh
|
||||
npm install unist-util-stringify-position
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
```js
|
||||
var stringify = require('unist-util-stringify-position')
|
||||
|
||||
// Point
|
||||
stringify({line: 2, column: 3}) // => '2:3'
|
||||
|
||||
// Position
|
||||
stringify({start: {line: 2}, end: {line: 3}}) // => '2:1-3:1'
|
||||
|
||||
// Node
|
||||
stringify({
|
||||
type: 'text',
|
||||
value: '!',
|
||||
position: {
|
||||
start: {line: 5, column: 11},
|
||||
end: {line: 5, column: 12}
|
||||
}
|
||||
}) // => '5:11-5:12'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `stringifyPosition(node|position|point)`
|
||||
|
||||
Stringify one [point][], a [position][] (start and end [point][]s), or a node’s
|
||||
[positional information][positional-information].
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `node` ([`Node`][node])
|
||||
— Node whose `'position'` property to stringify
|
||||
* `position` ([`Position`][position])
|
||||
— Position whose `'start'` and `'end'` points to stringify
|
||||
* `point` ([`Point`][point])
|
||||
— Point whose `'line'` and `'column'` to stringify
|
||||
|
||||
###### Returns
|
||||
|
||||
`string?` — A range `ls:cs-le:ce` (when given `node` or `position`) or a point
|
||||
`l:c` (when given `point`), where `l` stands for line, `c` for column, `s` for
|
||||
`start`, and `e` for end.
|
||||
An empty string (`''`) is returned if the given value is neither `node`,
|
||||
`position`, nor `point`.
|
||||
|
||||
## Related
|
||||
|
||||
* [`unist-util-generated`](https://github.com/syntax-tree/unist-util-generated)
|
||||
— Check if a node is generated
|
||||
* [`unist-util-position`](https://github.com/syntax-tree/unist-util-position)
|
||||
— Get positional info of nodes
|
||||
* [`unist-util-remove-position`](https://github.com/syntax-tree/unist-util-remove-position)
|
||||
— Remove positional info from trees
|
||||
* [`unist-util-source`](https://github.com/syntax-tree/unist-util-source)
|
||||
— Get the source of a value (node or position) in a file
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
|
||||
started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definition -->
|
||||
|
||||
[build-badge]: https://img.shields.io/travis/syntax-tree/unist-util-stringify-position.svg
|
||||
|
||||
[build]: https://travis-ci.org/syntax-tree/unist-util-stringify-position
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-stringify-position.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/syntax-tree/unist-util-stringify-position
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/unist-util-stringify-position.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/unist-util-stringify-position
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/unist-util-stringify-position.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=unist-util-stringify-position
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-spectrum-7b16ff.svg
|
||||
|
||||
[chat]: https://spectrum.chat/unified/syntax-tree
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md
|
||||
|
||||
[support]: https://github.com/syntax-tree/.github/blob/master/support.md
|
||||
|
||||
[coc]: https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
|
||||
|
||||
[unist]: https://github.com/syntax-tree/unist
|
||||
|
||||
[node]: https://github.com/syntax-tree/unist#node
|
||||
|
||||
[position]: https://github.com/syntax-tree/unist#position
|
||||
|
||||
[point]: https://github.com/syntax-tree/unist#point
|
||||
|
||||
[positional-information]: https://github.com/syntax-tree/unist#positional-information
|
||||
9
node_modules/unist-util-stringify-position/types/index.d.ts
generated
vendored
Normal file
9
node_modules/unist-util-stringify-position/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
import * as Unist from 'unist'
|
||||
|
||||
declare function unistUtilStringifyPosition(
|
||||
value: Unist.Node | Unist.Position | Unist.Point
|
||||
): string
|
||||
|
||||
export = unistUtilStringifyPosition
|
||||
Reference in New Issue
Block a user