Add support for copy and move operations (#1111)

This commit is contained in:
toasted-nutbread 2020-12-14 22:32:21 -05:00 committed by GitHub
parent 96e68be0fa
commit cd82fe8aac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,6 +122,24 @@ function applyModifications(manifest, modifications) {
value.splice(start, deleteCount, ...itemsNew);
}
break;
case 'copy':
{
const {newPath} = modification;
const value = getObjectProperties(manifest, path2, path2.length);
const newObject = getObjectProperties(manifest, newPath, newPath.length - 1);
newObject[newPath[newPath.length - 1]] = value;
}
break;
case 'move':
{
const {newPath} = modification;
const value = getObjectProperties(manifest, path2, path2.length);
const oldObject = getObjectProperties(manifest, path2, path2.length - 1);
const newObject = getObjectProperties(manifest, newPath, newPath.length - 1);
newObject[newPath[newPath.length - 1]] = value;
delete oldObject[path2[path2.length - 1]];
}
break;
}
}
}