UNPKG

@polgubau/utils

Version:

A collection of utility functions for TypeScript

61 lines 1.69 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var get_main_field_exports = {}; __export(get_main_field_exports, { DEFAULT_KEYS: () => DEFAULT_KEYS, getMainField: () => getMainField }); module.exports = __toCommonJS(get_main_field_exports); const DEFAULT_KEYS = [ "displayName", "name", "label", "title", "main", "code", "value", "userName", "locale", "id", "fullName", "shortName" ]; const 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; }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { DEFAULT_KEYS, getMainField }); //# sourceMappingURL=get-main-field.js.map