Sha256: c65e693a5709ca067df26d19afb61ea690b4d11b65daa4b5d427315a2ca956db
Contents?: true
Size: 761 Bytes
Versions: 54
Compression:
Stored size: 761 Bytes
Contents
function normaliseString(value, property) { const trimmedValue = value ? value.trim() : ''; let output; let outputType = property == null ? void 0 : property.type; if (!outputType) { if (['true', 'false'].includes(trimmedValue)) { outputType = 'boolean'; } if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) { outputType = 'number'; } } switch (outputType) { case 'boolean': output = trimmedValue === 'true'; break; case 'number': output = Number(trimmedValue); break; default: output = value; } return output; } /** * @typedef {import('./index.mjs').SchemaProperty} SchemaProperty */ export { normaliseString }; //# sourceMappingURL=normalise-string.mjs.map
Version data entries
54 entries across 54 versions & 3 rubygems