Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function applyDelete(ast: Program, uint8Buffer: Uint8Array, node: Node): State {
const deltaElements = -1; // since we removed an element
assertHasLoc(node);
const sectionName = getSectionForNode(node);
if (sectionName === "start") {
const sectionMetadata = getSectionMetadata(ast, "start");
/**
* The start section only contains one element,
* we need to remove the whole section
*/
uint8Buffer = removeSection(ast, uint8Buffer, "start");
const deltaBytes = -(sectionMetadata.size.value + 1) /* section id */;
return { uint8Buffer, deltaBytes, deltaElements };
}
// replacement is nothing
const replacement = [];
uint8Buffer = overrideBytesInBuffer(
uint8Buffer,
// $FlowIgnore: assertHasLoc ensures that
node.loc.start.column,
// $FlowIgnore: assertHasLoc ensures that
node.loc.end.column,
replacement