@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
28 lines • 765 B
JavaScript
import merge from "deepmerge";
const mergeByKey = (key) => {
return (target, source, options) => {
const destination = [];
const sourceMap = /* @__PURE__ */ new Map();
source.forEach((item) => {
sourceMap.set(item[key], item);
});
target.forEach((targetItem) => {
const sourceItem = sourceMap.get(targetItem[key]);
if (sourceItem) {
const mergedItem = merge(targetItem, sourceItem, options);
destination.push(mergedItem);
sourceMap.delete(targetItem[key]);
} else {
destination.push(targetItem);
}
});
sourceMap.forEach((item) => {
destination.push(item);
});
return destination;
};
};
export {
mergeByKey
};
//# sourceMappingURL=mergeDictionaries.mjs.map