Files
StudyDiary/.obsidian/plugins/marp-slides/lib3/markdown-it/@kazumatu981/markdown-it-kroki/lib/safe-property.js
T
2026-07-23 20:36:13 +08:00

16 lines
487 B
JavaScript
Executable File

'use strict';
function safeProperty(test, name, type, defaultValue) {
if (test == null || test == undefined) return defaultValue;
if (typeof test[name] !== type) return defaultValue;
if (typeof test[name] === "string" && test[name] === '') return defaultValue;
return test[name];
}
function safeChoice(test, candidates, defaultValue) {
return candidates.includes(test) ?
test : defaultValue;
}
module.exports = { safeProperty, safeChoice };