@carbon/ibm-security
Version:
Carbon for Cloud & Cognitive IBM Security UI components
22 lines (20 loc) • 720 B
JavaScript
/**
* @file Item helpers.
* @copyright IBM Security 2019
*/
/**
* Handles converting an item to a string.
* @param {Record<string, any>} item The object containing a label to convert.
* @returns {string} The converted label of the object passed.
*/
var convertItemToString = function convertItemToString(item) {
return typeof (item || {}).label === 'string' ? (item || {}).label : (item || {}).toString();
};
/**
* Handles returning a label for an object.
* @param {Record<string, any>} item The object containing a label.
* @returns {string} The label of the object passed.
*/
export default (function (item) {
return Array.isArray(item) ? item.map(convertItemToString) : convertItemToString(item);
});