site/node_modules/retext-stringify/lib/index.js

28 lines
627 B
JavaScript
Raw Normal View History

2024-10-14 06:09:33 +00:00
/**
* @typedef {import('nlcst').Root} Root
*/
import {toString} from 'nlcst-to-string'
/**
* Add support for serializing natural language.
*
* @returns {undefined}
* Nothing.
*/
export default function retextStringify() {
// eslint-disable-next-line unicorn/no-this-assignment
const self =
/** @type {import('unified').Processor<undefined, undefined, undefined, Root, string>} */ (
// @ts-expect-error -- TS in JSDoc doesnt understand `this`.
this
)
self.compiler = compiler
}
/** @type {import('unified').Compiler<Root, string>} */
function compiler(tree) {
return toString(tree)
}