@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
64 lines • 2.2 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var applyMask_exports = {};
__export(applyMask_exports, {
applyMask: () => applyMask
});
module.exports = __toCommonJS(applyMask_exports);
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;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
applyMask
});
//# sourceMappingURL=applyMask.cjs.map