unist-util-inspect
Advanced tools
Comparing version 4.1.3 to 4.1.4
34
index.js
@@ -5,4 +5,3 @@ 'use strict' | ||
/* Detect color support. */ | ||
// Detect color support. | ||
var color = true | ||
@@ -12,3 +11,3 @@ | ||
color = 'inspect' in require('util') | ||
} catch (err) { | ||
} catch (error) { | ||
/* istanbul ignore next - browser */ | ||
@@ -29,4 +28,4 @@ color = false | ||
/* Define ANSII color removal functionality. */ | ||
var COLOR_EXPRESSION = new RegExp( | ||
// Define ANSII color removal functionality. | ||
var colorExpression = new RegExp( | ||
'(?:' + | ||
@@ -43,8 +42,7 @@ '(?:\\u001b\\[)|' + | ||
/* Standard keys defined by unist: | ||
* https://github.com/syntax-tree/unist. | ||
* We don’t ignore `data` though. */ | ||
// Standard keys defined by unist: https://github.com/syntax-tree/unist. | ||
// We don’t ignore `data` though. | ||
var ignore = ['type', 'value', 'children', 'position'] | ||
/* Inspects a node, without using color. */ | ||
// Inspects a node, without using color. | ||
function noColor(node, pad) { | ||
@@ -54,3 +52,3 @@ return stripColor(inspect(node, pad)) | ||
/* Inspects a node. */ | ||
// Inspects a node. | ||
function inspect(node, pad) { | ||
@@ -104,3 +102,3 @@ var result | ||
/* Colored nesting formatter. */ | ||
// Colored nesting formatter. | ||
function formatNesting(value) { | ||
@@ -110,3 +108,3 @@ return dim(value) | ||
/* Compile a single position. */ | ||
// Compile a single position. | ||
function compile(pos) { | ||
@@ -128,3 +126,3 @@ var values = [] | ||
/* Compile a location. */ | ||
// Compile a location. | ||
function stringify(start, end) { | ||
@@ -148,3 +146,3 @@ var values = [] | ||
/* Add a position. */ | ||
// Add a position. | ||
function add(position) { | ||
@@ -163,3 +161,3 @@ var tuple = compile(position) | ||
/* Colored node formatter. */ | ||
// Colored node formatter. | ||
function formatNode(node) { | ||
@@ -205,8 +203,8 @@ var log = node.type | ||
/* Remove ANSI colour from `value`. */ | ||
// Remove ANSI colour from `value`. | ||
function stripColor(value) { | ||
return value.replace(COLOR_EXPRESSION, '') | ||
return value.replace(colorExpression, '') | ||
} | ||
/* Factory to wrap values in ANSI colours. */ | ||
// Factory to wrap values in ANSI colours. | ||
function ansiColor(open, close) { | ||
@@ -213,0 +211,0 @@ return color |
{ | ||
"name": "unist-util-inspect", | ||
"version": "4.1.3", | ||
"version": "4.1.4", | ||
"description": "Unist node inspector", | ||
@@ -14,5 +14,5 @@ "license": "MIT", | ||
"bugs": "https://github.com/syntax-tree/unist-util-inspect/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)", | ||
"contributors": [ | ||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)" | ||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)" | ||
], | ||
@@ -28,16 +28,16 @@ "files": [ | ||
"chalk": "^2.3.0", | ||
"esmangle": "^1.0.1", | ||
"nyc": "^11.0.0", | ||
"prettier": "^1.12.1", | ||
"remark-cli": "^5.0.0", | ||
"remark-preset-wooorm": "^4.0.0", | ||
"retext": "^5.0.0", | ||
"strip-ansi": "^4.0.0", | ||
"tape": "^4.4.0", | ||
"xo": "^0.20.0" | ||
"nyc": "^14.0.0", | ||
"prettier": "^1.0.0", | ||
"remark-cli": "^6.0.0", | ||
"remark-preset-wooorm": "^5.0.0", | ||
"retext": "^6.0.0", | ||
"strip-ansi": "^5.0.0", | ||
"tape": "^4.0.0", | ||
"tinyify": "^2.0.0", | ||
"xo": "^0.24.0" | ||
}, | ||
"scripts": { | ||
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix", | ||
"build-bundle": "browserify index.js --bare -s unistUtilInspect > unist-util-inspect.js", | ||
"build-mangle": "esmangle unist-util-inspect.js > unist-util-inspect.min.js", | ||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix", | ||
"build-bundle": "browserify . --bare -s unistUtilInspect > unist-util-inspect.js", | ||
"build-mangle": "browserify . --bare -s unistUtilInspect -p tinyify > unist-util-inspect.min.js", | ||
"build": "npm run build-bundle && npm run build-mangle", | ||
@@ -60,5 +60,3 @@ "test-api": "node test", | ||
"rules": { | ||
"guard-for-in": "off", | ||
"no-var": "off", | ||
"prefer-arrow-callback": "off" | ||
"guard-for-in": "off" | ||
}, | ||
@@ -65,0 +63,0 @@ "ignore": [ |
@@ -1,10 +0,18 @@ | ||
# unist-util-inspect [![Build Status][build-badge]][build-page] [![Coverage Status][coverage-badge]][coverage-page] | ||
# unist-util-inspect | ||
[Unist][] node inspector. | ||
[![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] | ||
## Installation | ||
[**unist**][unist] utility to inspect nodes. | ||
## Install | ||
[npm][]: | ||
```bash | ||
```sh | ||
npm install unist-util-inspect | ||
@@ -15,10 +23,14 @@ ``` | ||
```javascript | ||
var unified = require('unified') | ||
```js | ||
var u = require('unist-builder') | ||
var inspect = require('unist-util-inspect') | ||
var parse = require('rehype-parse') | ||
var tree = unified() | ||
.use(parse) | ||
.parse('<h2>Hello, world!</h2>') | ||
var tree = u('root', [ | ||
u('literal', '1'), | ||
u('parent', [ | ||
u('void', {id: 'a'}), | ||
u('literal', '2'), | ||
u('node', {id: 'b'}, []) | ||
]) | ||
]) | ||
@@ -31,8 +43,8 @@ console.log(inspect(tree)) | ||
```text | ||
root[1] (1:1-1:23, 0-22) [data={"quirksMode":true}] | ||
└─ element[2] [tagName="html"] | ||
├─ element[0] [tagName="head"] | ||
└─ element[1] [tagName="body"] | ||
└─ element[1] (1:1-1:23, 0-22) [tagName="h2"] | ||
└─ text: "Hello, world!" (1:5-1:18, 4-17) | ||
root[2] | ||
├─ literal: "1" | ||
└─ parent[3] | ||
├─ void [id="a"] | ||
├─ literal: "2" | ||
└─ node[0] [id="b"] | ||
``` | ||
@@ -55,3 +67,3 @@ | ||
### `inspect.<style>[.<style>...](node)` | ||
### `inspect.<style>[.<style>…](node)` | ||
@@ -65,7 +77,9 @@ Where `<style>` is either `color` or `noColor`. | ||
See [`contributing.md` in `syntax-tree/unist`][contributing] for ways to get | ||
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get | ||
started. | ||
See [`support.md`][support] for ways to get help. | ||
This organisation has a [Code of Conduct][coc]. By interacting with this | ||
repository, organisation, or community you agree to abide by its terms. | ||
This project has a [Code of Conduct][coc]. | ||
By interacting with this repository, organisation, or community you agree to | ||
abide by its terms. | ||
@@ -80,8 +94,26 @@ ## License | ||
[build-page]: https://travis-ci.org/syntax-tree/unist-util-inspect | ||
[build]: https://travis-ci.org/syntax-tree/unist-util-inspect | ||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-inspect.svg | ||
[coverage-page]: https://codecov.io/github/syntax-tree/unist-util-inspect?branch=master | ||
[coverage]: https://codecov.io/github/syntax-tree/unist-util-inspect | ||
[downloads-badge]: https://img.shields.io/npm/dm/unist-util-inspect.svg | ||
[downloads]: https://www.npmjs.com/package/unist-util-inspect | ||
[size-badge]: https://img.shields.io/bundlephobia/minzip/unist-util-inspect.svg | ||
[size]: https://bundlephobia.com/result?p=unist-util-inspect | ||
[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/join%20the%20community-on%20spectrum-7b16ff.svg | ||
[chat]: https://spectrum.chat/unified/syntax-tree | ||
[unist]: https://github.com/syntax-tree/unist | ||
@@ -93,8 +125,10 @@ | ||
[license]: LICENSE | ||
[license]: license | ||
[author]: http://wooorm.com | ||
[author]: https://wooorm.com | ||
[contributing]: https://github.com/syntax-tree/unist/blob/master/contributing.md | ||
[contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md | ||
[coc]: https://github.com/syntax-tree/unist/blob/master/code-of-conduct.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 |
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
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
9853
129
160