unist-util-generated

unist utility to check if a node is generated

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
unist-util-generated
402.0.113 days ago7 years agoMinified + gzip package size for unist-util-generated in KB

Readme

unist-util-generated
!Buildbuild-badgebuild !Coveragecoverage-badgecoverage !Downloadsdownloads-badgedownloads !Sizesize-badgesize !Sponsorssponsors-badgecollective !Backersbackers-badgecollective !Chatchat-badgechat
unist utility to check if a node is generated.

Contents

*   [`generated(node)`](#generatednode)

What is this?

This utility can be used to check if a node is said to be generatedgenerated-term.

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-positionunist-util-position useful to get clean positional info. To display positional info to users, use unist-util-stringify-positionunist-util-stringify-position.

Install

This package is ESM onlyesm. In Node.js (version 14.14+ and 16.0+), install with npm:
npm install unist-util-generated

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

In browsers with esm.shesmsh:
<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 generatedgenerated. There is no default export.

generated(node)

Check if node is generated.
Parameters
— 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.

Related

— get the position of nodes
— get the source of a node or position
— remove `position`s
— serialize positional info

Contribute

See contributing.mdcontributing in syntax-tree/.githubhealth for ways to get started. See support.mdsupport for ways to get help.
This project has a code of conductcoc. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MITlicense © Titus Wormerauthor