UNPKG

@intlayer/chokidar

Version:

Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.

40 lines 1.18 kB
const applyMask = (full, mask) => { if (mask === true) { return full; } if (Array.isArray(mask) && Array.isArray(full)) { return mask.map((m, i) => applyMask(full[i], m)); } if (full && typeof full === "object" && "nodeType" in full) { if (mask && typeof mask === "object") { return full; } return full; } if (mask && typeof mask === "object" && full && typeof full === "object") { const out = {}; const maskEntries = Object.entries(mask); const allChildrenAreArrays = maskEntries.every( ([, value]) => Array.isArray(value) ); for (const [k, m] of maskEntries) { const fullValue = full[k]; if (Array.isArray(m) && Array.isArray(fullValue)) { const isTranslationNode = (val) => !!val && typeof val === "object" && "nodeType" in val; const isArrayOfTranslationNodes = fullValue.every( (item) => isTranslationNode(item) ); if (!allChildrenAreArrays && !isArrayOfTranslationNodes) { continue; } } out[k] = applyMask(fullValue, m); } return out; } return full; }; export { applyMask }; //# sourceMappingURL=applyMask.mjs.map