Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@webassemblyjs/wasm-opt

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webassemblyjs/wasm-opt - npm Package Compare versions

Comparing version 1.2.8 to 1.3.0

test/index.js

49

lib/index.js

@@ -6,9 +6,46 @@ "use strict";

});
Object.defineProperty(exports, "shrinkPaddedLEB128", {
enumerable: true,
get: function get() {
return _leb.shrinkPaddedLEB128;
exports.shrinkPaddedLEB128 = shrinkPaddedLEB128;
var _wasmParser = require("@webassemblyjs/wasm-parser");
var _leb = require("./leb128.js");
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var OptimizerError =
/*#__PURE__*/
function (_Error) {
_inherits(OptimizerError, _Error);
function OptimizerError(name, initalError) {
var _this;
_classCallCheck(this, OptimizerError);
_this = _possibleConstructorReturn(this, (OptimizerError.__proto__ || Object.getPrototypeOf(OptimizerError)).call(this, "Error while optimizing: " + name + ": " + initalError.message));
_this.stack = initalError.stack;
return _this;
}
});
var _leb = require("./leb128.js");
return OptimizerError;
}(Error);
var decoderOpts = {
ignoreCodeSection: true,
ignoreDataSection: true
};
function shrinkPaddedLEB128(uint8Buffer) {
try {
var ast = (0, _wasmParser.decode)(uint8Buffer.buffer, decoderOpts);
return (0, _leb.shrinkPaddedLEB128)(ast, uint8Buffer);
} catch (e) {
throw new OptimizerError("shrinkPaddedLEB128", e);
}
}

9

lib/leb128.js

@@ -10,4 +10,2 @@ "use strict";

var _wasmParser = require("@webassemblyjs/wasm-parser");
var _encoder = require("@webassemblyjs/wasm-gen/lib/encoder");

@@ -38,8 +36,3 @@

function shrinkPaddedLEB128(uint8Buffer) {
var opts = {
ignoreCodeSection: true,
ignoreDataSection: true
};
var ast = (0, _wasmParser.decode)(uint8Buffer.buffer, opts);
function shrinkPaddedLEB128(ast, uint8Buffer) {
(0, _ast.traverse)(ast, {

@@ -46,0 +39,0 @@ SectionMetadata: function SectionMetadata(_ref2) {

{
"name": "@webassemblyjs/wasm-opt",
"version": "1.2.8",
"version": "1.3.0",
"description": "",

@@ -19,7 +19,7 @@ "main": "lib/index.js",

"dependencies": {
"@webassemblyjs/ast": "1.2.8",
"@webassemblyjs/helper-buffer": "1.2.8",
"@webassemblyjs/wasm-gen": "1.2.8",
"@webassemblyjs/wasm-parser": "1.2.8"
"@webassemblyjs/ast": "1.3.0",
"@webassemblyjs/helper-buffer": "1.3.0",
"@webassemblyjs/wasm-gen": "1.3.0",
"@webassemblyjs/wasm-parser": "1.3.0"
}
}
// @flow
export { shrinkPaddedLEB128 } from "./leb128.js";
import { decode } from "@webassemblyjs/wasm-parser";
class OptimizerError extends Error {
constructor(name, initalError) {
super("Error while optimizing: " + name + ": " + initalError.message);
this.stack = initalError.stack;
}
}
const decoderOpts = {
ignoreCodeSection: true,
ignoreDataSection: true
};
import { shrinkPaddedLEB128 as makeShrinkPaddedLEB128 } from "./leb128.js";
export function shrinkPaddedLEB128(uint8Buffer: Uint8Array): Uint8Array {
try {
const ast = decode(uint8Buffer.buffer, decoderOpts);
return makeShrinkPaddedLEB128(ast, uint8Buffer);
} catch (e) {
throw new OptimizerError("shrinkPaddedLEB128", e);
}
}
// @flow
import { traverse } from "@webassemblyjs/ast";
import { decode } from "@webassemblyjs/wasm-parser";
import { encodeU32 } from "@webassemblyjs/wasm-gen/lib/encoder";

@@ -34,10 +33,6 @@ import { overrideBytesInBuffer } from "@webassemblyjs/helper-buffer";

export function shrinkPaddedLEB128(uint8Buffer: Uint8Array): Uint8Array {
const opts = {
ignoreCodeSection: true,
ignoreDataSection: true
};
const ast = decode(uint8Buffer.buffer, opts);
export function shrinkPaddedLEB128(
ast: Program,
uint8Buffer: Uint8Array
): Uint8Array {
traverse(ast, {

@@ -44,0 +39,0 @@ SectionMetadata({ node }) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc