@cognigy/rest-api-client
Version:
Cognigy REST-Client
11 lines • 522 B
JavaScript
export const determineMetadata = (jsonData) => {
// Check if jsonData is undefined or null and return an empty object if so
if (jsonData === undefined || jsonData === null) {
return {};
}
// Determine if jsonData is an array or an object and return the metadata object accordingly
return Array.isArray(jsonData)
? jsonData.length > 0 ? { metadata: jsonData } : {}
: Object.keys(jsonData).length > 0 ? { metadata: jsonData } : {};
};
//# sourceMappingURL=determineMetadata.js.map