$ cnpm install mdast-util-definitions
mdast utility to find definitions by identifier
.
This package is a tiny utility that lets you find definitions.
This utility can be useful because definitions can occur after the things that reference them. It’s small and protects against prototype pollution.
This package is ESM only. In Node.js (version 12.20+, 14.14+, or 16.0+), install with npm:
npm install mdast-util-definitions
In Deno with esm.sh
:
import {definitions} from 'https://esm.sh/mdast-util-definitions@5'
In browsers with esm.sh
:
<script type="module">
import {definitions} from 'https://esm.sh/mdast-util-definitions@5?bundle'
</script>
import {fromMarkdown} from 'mdast-util-from-markdown'
import {definitions} from 'mdast-util-definitions'
const tree = fromMarkdown('[example]: https://example.com "Example"')
const definition = definitions(tree)
definition('example')
// => {type: 'definition', 'title': 'Example', …}
definition('foo')
// => null
This package exports the identifier definitions
.
There is no default export.
definitions(node)
Find definitions in node
(Node
).
Uses CommonMark precedence, which means that earlier definitions are preferred
over duplicate later definitions.
definition
(Function
).
definition(identifier)
Get a node from the bound definition cache by its identifier
(string
).
Definition, if found (Node?
)
This package is fully typed with TypeScript. There are no additional exported types.
Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 12.20+, 14.14+, and 16.0+. Our projects sometimes work with older versions, but this is not guaranteed.
Use of mdast-util-definitions
does not involve hast or user content so
there are no openings for cross-site scripting (XSS) attacks.
Additionally, safe guards are in place to protect against prototype poisoning.
unist-util-index
— index property values or computed keys to nodesSee 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.
Copyright 2013 - present © cnpmjs.org