UNPKG

@parischap/pretty-print

Version:
55 lines (53 loc) 2.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fromOption = void 0; var _effect = /*#__PURE__*/require("effect"); var PPMarkShower = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./MarkShower.js")); var PPStyleMap = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("./StyleMap.js")); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /** * This module implements a Type that builds a MarkShower (see MarkShower.ts) from an Option (see * Option.ts) and a markName */ /** * 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 */ const fromOption = option => { const markShowerMap = _effect.HashMap.map(option.markMap.marks, ({ text, partName }) => (0, _effect.pipe)(option.styleMap, PPStyleMap.get(partName), contextStyler => contextStyler.withContextLast(text))); return markName => (0, _effect.pipe)(markShowerMap, _effect.HashMap.get(markName), _effect.Option.getOrElse(_effect.Function.constant(PPMarkShower.empty))); }; exports.fromOption = fromOption; //# sourceMappingURL=MarkShowerConstructor.js.map