/** * @typedef {import('micromark-util-types').Event} Event * @typedef {import('micromark-util-types').Resolver} Resolver * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext */ /** * Call all `resolveAll`s. * * @param {Array<{resolveAll?: Resolver | undefined}>} constructs * List of constructs, optionally with `resolveAll`s. * @param {Array} events * List of events. * @param {TokenizeContext} context * Context used by `tokenize`. * @returns {Array} * Changed events. */ export function resolveAll(constructs, events, context) { /** @type {Array} */ 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 }