@intlayer/core
Version:
Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.
1 lines • 1.05 kB
Source Map (JSON)
{"version":3,"sources":["../../../../src/transpiler/condition/condition.ts"],"sourcesContent":["import {\n formatNodeType,\n NodeType,\n type TypedNodeModel,\n} from '../../types/index';\n\nexport type ConditionContentStates<Content> = Record<`${boolean}`, Content> & {\n fallback?: Content;\n};\n\nexport type ConditionContent<Content = unknown> = TypedNodeModel<\n NodeType.Condition,\n ConditionContentStates<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a condition.\n *\n * Usage:\n *\n * ```ts\n * cond({\n * 'true': 'The condition is validated',\n * 'false': 'The condition is not validated',\n * });\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n */\nconst condition = <Content>(content?: ConditionContentStates<Content>) =>\n formatNodeType(NodeType.Condition, content);\n\nexport { condition as cond };\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AA4BP,MAAM,YAAY,CAAU,YAC1B,eAAe,SAAS,WAAW,OAAO;","names":[]}