UNPKG

@rshirohara/repixe-rekurke

Version:

repixe plugin that turns pixiv novel format into kakuyomu novel format to support rekurke.

32 lines (31 loc) 972 B
import { toKkast } from "./lib/index.js"; /** * Turn pixiv novel format into Kakuyomu novel format. * * ##### Notes * * ###### Signature * * - if a processor is given, runs the (rekurke) plugins used on it with a * kkast tree, then discards the result. (*bridge mode*) * - otherwise, returns a kkast tree, the plugins used after `repixeRekurke` * are rekurke plugins. (*mutate mode*) * * @overload * @param {Processor} processor * @param {Readonly<Options> | null | undefined} options * @returns {TransformBridge} * * @overload * @param {Readonly<Options> | null | undefined} options * @returns {TransformMutate} */ export function repixeRekurke(destination, options) { if (destination && "run" in destination) { return async (tree, file) => { const kkastTree = toKkast(tree, options); await destination.run(kkastTree, file); }; } return (tree, _file) => toKkast(tree, destination ?? options); }