json-schema-describes-subset
Version:
Tools for static JSON schema analysis, including functions to determine if one schema describes a subset of another or if a schema describes the empty set or to convert a schema to its disjunctive normal form (DNF).
16 lines • 455 B
JavaScript
export function groupByAndMap(array, getKey, map) {
const result = {};
for (const value of array) {
const key = getKey(value);
const mappedValue = map(value);
const arrayForKey = result[key];
if (arrayForKey === undefined) {
result[key] = [mappedValue];
}
else {
arrayForKey.push(mappedValue);
}
}
return result;
}
//# sourceMappingURL=group-by-and-map.js.map