@polgubau/utils
Version:
A collection of utility functions for TypeScript
37 lines • 658 B
JavaScript
// src/objects/get-main-field/get-main-field.ts
var DEFAULT_KEYS = [
"displayName",
"name",
"label",
"title",
"main",
"code",
"value",
"userName",
"locale",
"id",
"fullName",
"shortName"
];
var getMainField = (item) => {
const label = DEFAULT_KEYS.find((label2) => {
const value = item?.[label2];
if (value) {
return true;
}
});
if (label) {
const value = item[label];
return { key: label, value };
}
const object = {
key: Object.keys(item)[0],
value: item[Object.keys(item)[0]]
};
return object;
};
export {
DEFAULT_KEYS,
getMainField
};
//# sourceMappingURL=get-main-field.mjs.map