@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
42 lines • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Cast = void 0;
class Cast {
static toString(v) {
if (v === null || v === undefined)
return '';
if (typeof v === 'string')
return v;
if (typeof v === 'number')
return v.toString();
if (typeof v === 'boolean')
return v.toString();
return String(v);
}
static toInt(v) {
if (v === null || v === undefined)
return 0;
if (typeof v === 'number')
return Math.floor(v);
if (typeof v === 'string') {
const parsed = parseInt(v, 10);
return isNaN(parsed) ? 0 : parsed;
}
return 0;
}
static toTime(v) {
if (v === null || v === undefined)
return new Date();
if (v instanceof Date)
return v;
if (typeof v === 'string') {
const parsed = new Date(v);
return isNaN(parsed.getTime()) ? new Date() : parsed;
}
if (typeof v === 'number')
return new Date(v);
return new Date();
}
}
exports.Cast = Cast;
//# sourceMappingURL=cast.js.map