Socket
Socket
Sign inDemoInstall

unist-util-generated

Package Overview
Dependencies
0
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.0.1

lib/index.d.ts

33

index.d.ts

@@ -1,32 +0,1 @@

/**
* @typedef {Object} PointLike
* @property {number} [line]
* @property {number} [column]
* @property {number} [offset]
*
* @typedef {Object} PositionLike
* @property {PointLike} [start]
* @property {PointLike} [end]
*
* @typedef {Object} NodeLike
* @property {PositionLike} [position]
*/
/**
* Check if `node` is *generated*.
*
* @param {NodeLike} [node]
* @returns {boolean}
*/
export function generated(node?: NodeLike): boolean
export type PointLike = {
line?: number
column?: number
offset?: number
}
export type PositionLike = {
start?: PointLike
end?: PointLike
}
export type NodeLike = {
position?: PositionLike
}
export {generated} from './lib/index.js'

@@ -1,32 +0,1 @@

/**
* @typedef {Object} PointLike
* @property {number} [line]
* @property {number} [column]
* @property {number} [offset]
*
* @typedef {Object} PositionLike
* @property {PointLike} [start]
* @property {PointLike} [end]
*
* @typedef {Object} NodeLike
* @property {PositionLike} [position]
*/
/**
* Check if `node` is *generated*.
*
* @param {NodeLike} [node]
* @returns {boolean}
*/
export function generated(node) {
return (
!node ||
!node.position ||
!node.position.start ||
!node.position.start.line ||
!node.position.start.column ||
!node.position.end ||
!node.position.end.line ||
!node.position.end.column
)
}
export {generated} from './lib/index.js'
{
"name": "unist-util-generated",
"version": "2.0.0",
"version": "2.0.1",
"description": "unist utility to check if a node is generated",

@@ -30,2 +30,3 @@ "license": "MIT",

"files": [
"lib/",
"index.d.ts",

@@ -35,19 +36,17 @@ "index.js"

"devDependencies": {
"@types/tape": "^4.0.0",
"@types/node": "^18.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"xo": "^0.38.0"
"xo": "^0.53.0"
},
"scripts": {
"prepack": "npm run build && npm run format",
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"

@@ -64,7 +63,3 @@ },

"xo": {
"prettier": true,
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
}
"prettier": true
},

@@ -71,0 +66,0 @@ "remarkConfig": {

@@ -11,11 +11,40 @@ # unist-util-generated

[**unist**][unist] utility to check if a [node][] is [*generated*][generated].
[unist][] utility to check if a node is generated.
## Contents
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`generated(node)`](#generatednode)
* [Types](#types)
* [Compatibility](#compatibility)
* [Related](#related)
* [Contribute](#contribute)
* [License](#license)
## What is this?
This utility can be used to check if a node is said to be
[generated][generated-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-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].
## Install
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
This package is [ESM only][esm].
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
[npm][]:
```sh

@@ -25,2 +54,16 @@ npm install unist-util-generated

In Deno with [`esm.sh`][esmsh]:
```js
import {generated} from 'https://esm.sh/unist-util-generated@2'
```
In browsers with [`esm.sh`][esmsh]:
```html
<script type="module">
import {generated} from 'https://esm.sh/unist-util-generated@2?bundle'
</script>
```
## Use

@@ -42,3 +85,3 @@

This package exports the following identifiers: `generated`.
This package exports the identifier [`generated`][generated].
There is no default export.

@@ -48,27 +91,40 @@

Check if [`node`][node] is [*generated*][generated].
Check if `node` is generated.
###### Parameters
* `node` ([`Node`][node]) — Node to check.
* `node` ([`Node`][node])
— node to check
###### Returns
`boolean` — Whether `node` is generated.
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
* [`unist-util-position`](https://github.com/syntax-tree/unist-util-position)
— Get the position of nodes
— get the position of nodes
* [`unist-util-source`](https://github.com/syntax-tree/unist-util-source)
— Get the source of a node or position
— get the source of a node or position
* [`unist-util-remove-position`](https://github.com/syntax-tree/unist-util-remove-position)
— Remove `position`s from a tree
— remove `position`s
* [`unist-util-stringify-position`](https://github.com/syntax-tree/unist-util-stringify-position)
— Stringify a node, position, or point
— serialize positional info
## Contribute
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
started.
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
ways to get started.
See [`support.md`][support] for ways to get help.

@@ -114,2 +170,8 @@

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esmsh]: https://esm.sh
[typescript]: https://www.typescriptlang.org
[license]: license

@@ -119,8 +181,10 @@

[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
[health]: https://github.com/syntax-tree/.github
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.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

@@ -130,2 +194,8 @@

[generated]: https://github.com/syntax-tree/unist#generated
[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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc