At the moment, the following test is failling because during patching we won't add the KVP new_root = 42 above the mytable inline table even if it appears before it in the JS Object.
test.skip('should add new root key-value before inline table if appearing before in the patched object', () => {
const existing = dedent`
mytable = {
key = "value"
}
` + '\n';
const patched = patch(existing, {
new_root: 42,
mytable: { key: 'value' }
});
expect(patched).toEqual(dedent`
new_root = 42
mytable = {
key = "value"
}
` + '\n');
});
It would be nice to have this feature support where new entries are added relative to their position in the JS Object. However that would mean that we also have to re-order all other entries in the TOML file. Otherwise, it could cause issues if existing KVP were moved around and we wouldn't know where to insert the new entry if order of existing entries had flipped for instance.
This means that this would have to be a formatting option. Enabling it would mean that we would re-order all elements in the TOML output based on the order in the JS object even if those haven't changed value between the original TOML and the JS Object.
At the moment, the following test is failling because during patching we won't add the KVP
new_root = 42above themytableinline table even if it appears before it in the JS Object.It would be nice to have this feature support where new entries are added relative to their position in the JS Object. However that would mean that we also have to re-order all other entries in the TOML file. Otherwise, it could cause issues if existing KVP were moved around and we wouldn't know where to insert the new entry if order of existing entries had flipped for instance.
This means that this would have to be a formatting option. Enabling it would mean that we would re-order all elements in the TOML output based on the order in the JS object even if those haven't changed value between the original TOML and the JS Object.