Sha256: c6d4a2d1333ae8e8834af218aa5bdd8acc52bcd6819212b5a0196505eafd5f00

Contents?: true

Size: 1.41 KB

Versions: 26

Compression:

Stored size: 1.41 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.removeSections = removeSections;

var _ast = require("@webassemblyjs/ast");

var _helperBuffer = require("@webassemblyjs/helper-buffer");

function removeSections(ast, uint8Buffer, section) {
  var sectionMetadatas = (0, _ast.getSectionMetadatas)(ast, section);

  if (sectionMetadatas.length === 0) {
    throw new Error("Section metadata not found");
  }

  return sectionMetadatas.reverse().reduce(function (uint8Buffer, sectionMetadata) {
    var startsIncludingId = sectionMetadata.startOffset - 1;
    var ends = section === "start" ? sectionMetadata.size.loc.end.column + 1 : sectionMetadata.startOffset + sectionMetadata.size.value + 1;
    var delta = -(ends - startsIncludingId);
    /**
     * update AST
     */
    // Once we hit our section every that is after needs to be shifted by the delta

    var encounteredSection = false;
    (0, _ast.traverse)(ast, {
      SectionMetadata: function SectionMetadata(path) {
        if (path.node.section === section) {
          encounteredSection = true;
          return path.remove();
        }

        if (encounteredSection === true) {
          (0, _ast.shiftSection)(ast, path.node, delta);
        }
      }
    }); // replacement is nothing

    var replacement = [];
    return (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, startsIncludingId, ends, replacement);
  }, uint8Buffer);
}

Version data entries

26 entries across 25 versions & 8 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
disco_app-0.18.0 test/dummy/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
disco_app-0.18.2 test/dummy/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
disco_app-0.16.1 test/dummy/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
disco_app-0.15.2 test/dummy/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
disco_app-0.18.4 test/dummy/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
disco_app-0.18.1 test/dummy/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
disco_app-0.14.0 test/dummy/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
tang-0.2.1 spec/tang_app/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
tang-0.2.0 spec/tang_app/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
tang-0.1.0 spec/tang_app/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
tang-0.0.9 spec/tang_app/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
enju_library-0.3.8 spec/dummy/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js
jester-data-8.0.0 node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js