🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
22
node_modules/mdast-util-definitions/lib/index.d.ts
generated
vendored
Normal file
22
node_modules/mdast-util-definitions/lib/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Find definitions in `tree`.
|
||||
*
|
||||
* Uses CommonMark precedence, which means that earlier definitions are
|
||||
* preferred over duplicate later definitions.
|
||||
*
|
||||
* @param {Node} tree
|
||||
* Tree to check.
|
||||
* @returns {GetDefinition}
|
||||
* Getter.
|
||||
*/
|
||||
export function definitions(tree: Node): GetDefinition
|
||||
export type Root = import('mdast').Root
|
||||
export type Content = import('mdast').Content
|
||||
export type Definition = import('mdast').Definition
|
||||
export type Node = Root | Content
|
||||
/**
|
||||
* Get a definition by identifier.
|
||||
*/
|
||||
export type GetDefinition = (
|
||||
identifier?: string | null | undefined
|
||||
) => Definition | null
|
||||
64
node_modules/mdast-util-definitions/lib/index.js
generated
vendored
Normal file
64
node_modules/mdast-util-definitions/lib/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* @typedef {import('mdast').Root} Root
|
||||
* @typedef {import('mdast').Content} Content
|
||||
* @typedef {import('mdast').Definition} Definition
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Root | Content} Node
|
||||
*
|
||||
* @callback GetDefinition
|
||||
* Get a definition by identifier.
|
||||
* @param {string | null | undefined} [identifier]
|
||||
* Identifier of definition.
|
||||
* @returns {Definition | null}
|
||||
* Definition corresponding to `identifier` or `null`.
|
||||
*/
|
||||
|
||||
import {visit} from 'unist-util-visit'
|
||||
|
||||
const own = {}.hasOwnProperty
|
||||
|
||||
/**
|
||||
* Find definitions in `tree`.
|
||||
*
|
||||
* Uses CommonMark precedence, which means that earlier definitions are
|
||||
* preferred over duplicate later definitions.
|
||||
*
|
||||
* @param {Node} tree
|
||||
* Tree to check.
|
||||
* @returns {GetDefinition}
|
||||
* Getter.
|
||||
*/
|
||||
export function definitions(tree) {
|
||||
/** @type {Record<string, Definition>} */
|
||||
const cache = Object.create(null)
|
||||
|
||||
if (!tree || !tree.type) {
|
||||
throw new Error('mdast-util-definitions expected node')
|
||||
}
|
||||
|
||||
visit(tree, 'definition', (definition) => {
|
||||
const id = clean(definition.identifier)
|
||||
if (id && !own.call(cache, id)) {
|
||||
cache[id] = definition
|
||||
}
|
||||
})
|
||||
|
||||
return definition
|
||||
|
||||
/** @type {GetDefinition} */
|
||||
function definition(identifier) {
|
||||
const id = clean(identifier)
|
||||
// To do: next major: return `undefined` when not found.
|
||||
return id && own.call(cache, id) ? cache[id] : null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string | null | undefined} [value]
|
||||
* @returns {string}
|
||||
*/
|
||||
function clean(value) {
|
||||
return String(value || '').toUpperCase()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue