HckApm/node_modules/unist-util-generated
minicx 99e5f883a3 second commit 2023-12-23 14:56:27 +03:00
..
lib second commit 2023-12-23 14:56:27 +03:00
index.d.ts second commit 2023-12-23 14:56:27 +03:00
index.js second commit 2023-12-23 14:56:27 +03:00
license second commit 2023-12-23 14:56:27 +03:00
package.json second commit 2023-12-23 14:56:27 +03:00
readme.md second commit 2023-12-23 14:56:27 +03:00

readme.md

unist-util-generated

Build Coverage Downloads Size Sponsors Backers Chat

unist utility to check if a node is generated.

Contents

What is this?

This utility can be used to check if a node is said to be generated.

When should I use this?

You can use this utility to check is generated. Generated nodes were not in the source of the original file, and thus not authored by a human. This info can then be used to not emit lint messages for generated content.

You might also find the utility unist-util-position useful to get clean positional info. To display positional info to users, use unist-util-stringify-position.

Install

This package is ESM only. In Node.js (version 14.14+ and 16.0+), install with npm:

npm install unist-util-generated

In Deno with esm.sh:

import {generated} from 'https://esm.sh/unist-util-generated@2'

In browsers with esm.sh:

<script type="module">
  import {generated} from 'https://esm.sh/unist-util-generated@2?bundle'
</script>

Use

import {generated} from 'unist-util-generated'

generated({}) // => true

generated({position: {start: {}, end: {}}}) // => true

generated({
  position: {start: {line: 1, column: 1}, end: {line: 1, column: 2}}
}) // => false

API

This package exports the identifier generated. There is no default export.

generated(node)

Check if node is generated.

Parameters
  • node (Node) — node to check
Returns

Whether node is generated (does not have positional info) (boolean).

Types

This package is fully typed with TypeScript. It exports no additional types.

Compatibility

Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. Our projects sometimes work with older versions, but this is not guaranteed.

Contribute

See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer