unist utility to check if a node is generated
npm install unist-util-generated[![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][] utility to check if a node is generated.
* What is this?
* When should I use this?
* Install
* Use
* API
* generated(node)
* Types
* Compatibility
* Related
* Contribute
* License
This utility can be used to check if a node is said to be
[generated][generated-term].
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][unist-util-position]
useful to get clean positional info.
To display positional info to users, use
[unist-util-stringify-position][unist-util-stringify-position].
This package is [ESM only][esm].
In Node.js (version 16+), install with [npm][]:
``sh`
npm install unist-util-generated
In Deno with [esm.sh][esmsh]:
`js`
import {generated} from 'https://esm.sh/unist-util-generated@3'
In browsers with [esm.sh][esmsh]:
`html`
`js
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
`
This package exports the identifier [generated][generated].
There is no default export.
Check if node is generated.
###### Parameters
* node ([Node][node])
— node to check
###### Returns
Whether node is generated (does not have positional info) (boolean).
This package is fully typed with [TypeScript][].
It exports no additional types.
Projects maintained by the unified collective are compatible with maintained
versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, unist-util-generated@^2,
compatible with Node.js 16.
* unist-util-position
— get the position of nodes
* unist-util-source
— get the source of a node or position
* unist-util-remove-position
— remove positionsunist-util-stringify-position
*
— serialize positional info
See [contributing.md][contributing] in [syntax-tree/.github][health] forsupport.md`][support] for ways to get help.
ways to get started.
See [
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
[MIT][license] © [Titus Wormer][author]
[build-badge]: https://github.com/syntax-tree/unist-util-generated/workflows/main/badge.svg
[build]: https://github.com/syntax-tree/unist-util-generated/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-generated.svg
[coverage]: https://codecov.io/github/syntax-tree/unist-util-generated
[downloads-badge]: https://img.shields.io/npm/dm/unist-util-generated.svg
[downloads]: https://www.npmjs.com/package/unist-util-generated
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=unist-util-generated
[size]: https://bundlejs.com/?q=unist-util-generated
[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-discussions-success.svg
[chat]: https://github.com/syntax-tree/unist/discussions
[npm]: https://docs.npmjs.com/cli/install
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esmsh]: https://esm.sh
[typescript]: https://www.typescriptlang.org
[license]: license
[author]: https://wooorm.com
[health]: https://github.com/syntax-tree/.github
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
[unist]: https://github.com/syntax-tree/unist
[node]: https://github.com/syntax-tree/unist#node
[generated-term]: https://github.com/syntax-tree/unist#generated
[unist-util-position]: https://github.com/syntax-tree/unist-util-position
[unist-util-stringify-position]: https://github.com/syntax-tree/unist-util-stringify-position
[generated]: #generatednode