MCPcopy
hub / github.com/tailwindlabs/tailwindcss / convert

Function convert

packages/@tailwindcss-cli/src/utils/args.ts:131–150  ·  view source on GitHub ↗
(value: string | boolean, type: T)

Source from the content-addressed store, hash-verified

129// this is coming from `mri`'s parse function'), to the correct type based on
130// the `type` of the argument.
131function convert<T extends keyof Types>(value: string | boolean, type: T) {
132 switch (type) {
133 case 'string':
134 return convertString(value)
135 case 'boolean':
136 return convertBoolean(value)
137 case 'number':
138 return convertNumber(value)
139 case 'boolean | string':
140 return convertBoolean(value) ?? convertString(value)
141 case 'number | string':
142 return convertNumber(value) ?? convertString(value)
143 case 'boolean | number':
144 return convertBoolean(value) ?? convertNumber(value)
145 case 'boolean | number | string':
146 return convertBoolean(value) ?? convertNumber(value) ?? convertString(value)
147 default:
148 throw new Error(`Unhandled type: ${type}`)
149 }
150}
151
152function convertBoolean(value: ArgumentType) {
153 if (value === true || value === false) {

Callers 1

argsFunction · 0.70

Calls 3

convertStringFunction · 0.70
convertBooleanFunction · 0.70
convertNumberFunction · 0.70

Tested by

no test coverage detected