@parischap/pretty-print
Version:
A functional library to pretty-print and treeify objects
22 lines • 1.02 kB
JavaScript
/**
* This module implements a Type that builds a MarkShower (see MarkShower.ts) from an Option (see
* Option.ts) and a markName
*/
import { Function, HashMap, Option, pipe } from 'effect';
import * as PPMarkShower from './MarkShower.js';
import * as PPStyleMap from './StyleMap.js';
/**
* Creates a MarkShowerConstructor that will return a MarkShower from `markName` and `option`.
* Concretely, this markShower will display the text attached to markName in option.markMap using
* the reversed action of the ValueBasedContextStyler attached to markName in option.markMap
*
* @category Constructors
*/
export const fromOption = option => {
const markShowerMap = HashMap.map(option.markMap.marks, ({
text,
partName
}) => pipe(option.styleMap, PPStyleMap.get(partName), contextStyler => contextStyler.withContextLast(text)));
return markName => pipe(markShowerMap, HashMap.get(markName), Option.getOrElse(Function.constant(PPMarkShower.empty)));
};
//# sourceMappingURL=MarkShowerConstructor.js.map