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).
15 lines • 451 B
JavaScript
/**
* @param data Must be pure data and not contain functions etc. May contain non
* JSON data (e. g. `undefined`)
*
*/
export function cloneData(data) {
if (Array.isArray(data)) {
return data.map(cloneData);
}
if (typeof data === 'object' && data !== null) {
return Object.fromEntries(Object.entries(data).map(([key, value]) => [key, cloneData(value)]));
}
return data;
}
//# sourceMappingURL=clone-data.js.map