@seasketch/geoprocessing
Version:
Geoprocessing and reporting framework for SeaSketch 2.0
17 lines • 589 B
JavaScript
import { hasOwnProperty } from "../helpers/native.js";
/**
* Reorders object, mutating in place, in the order provided
*/
export const rekeyObject = (inputObject, idOrder) => {
const newObject = {};
for (const id of idOrder) {
if (hasOwnProperty(inputObject, id))
newObject[id] = inputObject[id];
}
// Put all other properties not in idOrder at the end
for (const id of Object.keys(inputObject).filter((id) => !idOrder.includes(id))) {
newObject[id] = inputObject[id];
}
return newObject;
};
//# sourceMappingURL=rekeyObject.js.map