@toreda/strong-types
Version:
Better TypeScript code in fewer lines.
1 lines • 1.48 kB
Source Map (JSON)
{"version":3,"sources":["../src/strong/make.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAIjC;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EACvB,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GACnB,MAAM,CAAC,MAAM,CAAC,CAIhB","file":"make.d.ts","sourcesContent":["import {Rules} from '../rules';\nimport {Strong} from '../strong';\nimport {createType} from '../create/type';\nimport {initialValue} from '../initial/value';\n\n/**\n * Create Strong object using provided arguments. Should generally be called\n * by helper functions or factories which create the desired type and pass in\n * type rules consistently.\n * @param fallback\t\tValue returned when type's current `value` is null.\n * @param initial\t\t(Optional) Initial value for type. When not provided, type's\n *\t\t\t\t\t\tinitial value is `fallback` instead. When reset is called, value\n *\t\t\t\t\t\tis automatically set to initial if it was provided, or fallback if not.\n * @param rules\t\t\tAutomatic type validation rules applied to any value used with `set`.\n * @returns\n *\n * @category Core\n */\nexport function strongMake<ValueT>(\n\tfallback: ValueT,\n\tinitial?: ValueT | null,\n\trules?: Rules<ValueT>\n): Strong<ValueT> {\n\tconst rulesValue = rules instanceof Rules ? rules : new Rules();\n\n\treturn createType<ValueT>(fallback, initialValue(initial), rulesValue, 'StrongType');\n}\n"]}