Gathering detailed insights and metrics for unist-util-position
Gathering detailed insights and metrics for unist-util-position
Gathering detailed insights and metrics for unist-util-position
Gathering detailed insights and metrics for unist-util-position
unist-util-position-from-estree
unist utility to get a position from an estree node
unist-util-stringify-position
unist utility to serialize a node, position, or point as a human readable location
unist-util-remove-position
unist utility to remove positions from a tree
unist-util-generated
unist utility to check if a node is generated
npm install unist-util-position
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
8 Stars
136 Commits
2 Forks
10 Watching
1 Branches
12 Contributors
Updated on 03 Jan 2023
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-1%
1,387,110
Compared to previous day
Last week
4.7%
7,350,108
Compared to previous week
Last month
14.5%
30,467,370
Compared to previous month
Last year
6.3%
317,349,470
Compared to previous year
1
unist utility to get positional info of nodes.
This utility helps with accessing positional info on a potentially dirty tree.
The positional info is typically consistent and proper in unist trees generated by our ecosystem, but, user plugins could mess that up. If you’re making a reusable plugin, and accessing the positional info often, you might want to guard against that by using this utility.
You might also find the utility unist-util-generated
useful to check whether a node is considered to be generated (not in the
original input file).
You might also enjoy
unist-util-stringify-position
when you want
to display positional info to users.
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install unist-util-position
In Deno with esm.sh
:
1import {pointEnd, pointStart, position} from 'https://esm.sh/unist-util-position@5'
In browsers with esm.sh
:
1<script type="module"> 2 import {pointEnd, pointStart, position} from 'https://esm.sh/unist-util-position@5?bundle' 3</script>
1import {fromMarkdown} from 'mdast-util-from-markdown' 2import {pointEnd, pointStart, position} from 'unist-util-position' 3 4const tree = fromMarkdown('# foo\n\n* bar\n') 5 6console.log(position(tree)) 7console.log(pointStart(tree)) 8console.log(pointEnd(tree))
Yields:
1{start: {line: 1, column: 1, offset: 0}, end: {line: 4, column: 1, offset: 13}} 2{line: 1, column: 1, offset: 0} 3{line: 4, column: 1, offset: 13}
This package exports the identifiers pointEnd
,
pointStart
, and position
.
There is no default export.
position(node)
Get the positional info of node
.
node
(Node
)
— nodePosition, if valid (Position
or undefined
).
pointEnd(node)
Get the ending point of node
.
node
(Node
)
— nodePoint, if valid (Point
or undefined
).
pointStart(node)
Get the starting point of node
.
node
(Node
)
— nodePoint, if valid (Point
or undefined
).
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-position@^5
,
compatible with Node.js 16.
unist-util-stringify-position
— serialize a node, position, or point as a human readable locationunist-util-position-from-estree
— get a position from an estree nodeunist-util-remove-position
— remove positions from treeunist-util-generated
— check if a node is generatedunist-util-source
— get the source of a nodeSee 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.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
Found 3/30 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More