1
0
Files
sashinexists/node_modules/@weborigami/language/test/compiler/stripCodeLocations.js
2024-12-07 13:18:31 +11:00

19 lines
539 B
JavaScript

import { isPlainObject } from "@weborigami/async-tree";
// For comparison purposes, strip the `location` property added by the parser.
export function stripCodeLocations(parseResult) {
if (Array.isArray(parseResult)) {
return parseResult.map(stripCodeLocations);
} else if (isPlainObject(parseResult)) {
const result = {};
for (const key in parseResult) {
if (key !== "location") {
result[key] = stripCodeLocations(parseResult[key]);
}
}
return result;
} else {
return parseResult;
}
}