gpreview
Version:
Preview Ghost themes locally without a full Ghost installation
34 lines • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.pluralHelper = pluralHelper;
function pluralHelper(count, ...args) {
let options;
let singular = '';
let plural = '';
let empty = '';
if (args.length === 1 && typeof args[0] === 'object' && args[0] !== null && 'hash' in args[0]) {
options = args[0];
const hash = options.hash || {};
singular = hash.singular || '';
plural = hash.plural || '';
empty = hash.empty || '';
}
else {
singular = typeof args[0] === 'string' ? args[0] : '';
plural = typeof args[1] === 'string' ? args[1] : '';
if (typeof args[1] === 'object') {
options = args[1];
plural = singular + 's';
}
else if (typeof args[2] === 'object') {
options = args[2];
}
}
const num = parseInt(String(count), 10) || 0;
if (num === 0 && empty) {
return empty.replace('%', '0');
}
const template = num === 1 ? singular : (plural || singular + 's');
return template.replace('%', num.toString());
}
//# sourceMappingURL=plural.js.map