site/node_modules/@citation-js/name/lib/output.js
2024-10-14 08:09:33 +02:00

26 lines
793 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
const startParts = ['dropping-particle', 'given'];
const suffixParts = ['suffix'];
const endParts = ['non-dropping-particle', 'family'];
const getName = function getName(name, reversed = false) {
const get = parts => parts.map(entry => name[entry] || '').filter(Boolean).join(' ');
if (name.literal) {
return name.literal;
} else if (reversed) {
const suffixPart = get(suffixParts) ? `, ${get(suffixParts)}` : '';
const startPart = get(startParts) ? `, ${get(startParts)}` : '';
return get(endParts) + suffixPart + startPart;
} else {
return `${get([...startParts, ...suffixParts, ...endParts])}`;
}
};
var _default = getName;
exports.default = _default;