kjelsrud.dev/node_modules/@mdx-js/mdx/lib/util/estree-util-create.js
2023-07-19 21:31:30 +02:00

27 lines
597 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @typedef {import('estree-jsx').Node} Node
*/
/**
* @param {Node} from
* Node to take from.
* @param {Node} to
* Node to add to.
* @returns {void}
* Nothing.
*/
export function create(from, to) {
/** @type {Array<keyof Node>} */
// @ts-expect-error: `start`, `end`, `comments` are custom Acorn fields.
const fields = ['start', 'end', 'loc', 'range', 'comments']
let index = -1
while (++index < fields.length) {
const field = fields[index]
if (field in from) {
// @ts-expect-error: assume theyre settable.
to[field] = from[field]
}
}
}