mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-20 18:49:13 +08:00
30 lines
736 B
Text
30 lines
736 B
Text
/**
|
|
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
|
|
* @typedef {import('micromark-util-types').Event} Event
|
|
* @typedef {import('micromark-util-types').Resolver} Resolver
|
|
*/
|
|
|
|
/**
|
|
* Call all `resolveAll`s.
|
|
*
|
|
* @param {{resolveAll?: Resolver}[]} constructs
|
|
* @param {Event[]} events
|
|
* @param {TokenizeContext} context
|
|
* @returns {Event[]}
|
|
*/
|
|
export function resolveAll(constructs, events, context) {
|
|
/** @type {Resolver[]} */
|
|
const called = []
|
|
let index = -1
|
|
|
|
while (++index < constructs.length) {
|
|
const resolve = constructs[index].resolveAll
|
|
|
|
if (resolve && !called.includes(resolve)) {
|
|
events = resolve(events, context)
|
|
called.push(resolve)
|
|
}
|
|
}
|
|
|
|
return events
|
|
}
|