@datocms/cma-client
Version:
JS client for DatoCMS REST Content Management API
20 lines • 754 B
JavaScript
export function isBlockOfType(itemTypeId, ...rest) {
const check = (block) => {
if (typeof block !== 'object' || block === null)
return false;
const relationships = block.relationships;
if (typeof relationships !== 'object' || relationships === null)
return false;
const itemType = relationships.item_type;
if (typeof itemType !== 'object' || itemType === null)
return false;
const data = itemType.data;
if (typeof data !== 'object' || data === null)
return false;
return data.id === itemTypeId;
};
if (rest.length > 0)
return check(rest[0]);
return (block) => check(block);
}
//# sourceMappingURL=isBlockOfType.js.map