UNPKG

caniemail

Version:

HTML and CSS Feature Support for Email Clients from caniemail.com

36 lines 1.45 kB
import { getProperty } from 'dot-prop'; import { getSupportType } from '../clients.js'; import { getFeatures } from '../features.js'; export const checkFeatures = ({ clients, issues, titles, position }) => { const { all: features } = getFeatures(); for (const title of [titles].flat()) { for (const client of clients) { const feature = features.get(title); if (feature === void 0) throw new RangeError(`Feature "${title}" not found.`); const { stats } = feature; const supportMap = getProperty(stats, client); if (supportMap === void 0) { throw new RangeError(`Feature "${title}" not found on "${client}".`); } const supportStatus = getSupportType(supportMap); const notes = (supportStatus.noteNumbers ?? []) .map((noteNumber) => feature.notes_by_num?.[String(noteNumber)]) .filter((note) => note !== undefined); const support = supportStatus.type; const issue = { notes, title, position, support }; if (support === 'none') { issues.errors.set(client, issue); } else if (support === 'partial') { issues.warnings.set(client, issue); } } } }; //# sourceMappingURL=check-features.js.map