@webassemblyjs/wasm-opt
Advanced tools
Comparing version 1.2.8 to 1.3.0
@@ -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); | ||
} | ||
} |
@@ -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 }) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8515
6
206
+ Added@webassemblyjs/ast@1.3.0(transitive)
+ Added@webassemblyjs/floating-point-hex-parser@1.3.0(transitive)
+ Added@webassemblyjs/helper-buffer@1.3.0(transitive)
+ Added@webassemblyjs/helper-code-frame@1.3.0(transitive)
+ Added@webassemblyjs/helper-fsm@1.3.0(transitive)
+ Added@webassemblyjs/helper-wasm-bytecode@1.3.0(transitive)
+ Added@webassemblyjs/leb128@1.3.0(transitive)
+ Added@webassemblyjs/validation@1.3.0(transitive)
+ Added@webassemblyjs/wasm-gen@1.3.0(transitive)
+ Added@webassemblyjs/wasm-parser@1.3.0(transitive)
+ Added@webassemblyjs/wast-parser@1.3.0(transitive)
+ Added@webassemblyjs/wast-printer@1.3.0(transitive)
+ Addedwebassemblyjs@1.3.0(transitive)
- Removed@webassemblyjs/ast@1.2.8(transitive)
- Removed@webassemblyjs/floating-point-hex-parser@1.2.8(transitive)
- Removed@webassemblyjs/helper-buffer@1.2.8(transitive)
- Removed@webassemblyjs/helper-code-frame@1.2.8(transitive)
- Removed@webassemblyjs/helper-fsm@1.2.8(transitive)
- Removed@webassemblyjs/helper-wasm-bytecode@1.2.8(transitive)
- Removed@webassemblyjs/leb128@1.2.8(transitive)
- Removed@webassemblyjs/validation@1.2.8(transitive)
- Removed@webassemblyjs/wasm-gen@1.2.8(transitive)
- Removed@webassemblyjs/wasm-parser@1.2.8(transitive)
- Removed@webassemblyjs/wast-parser@1.2.8(transitive)
- Removed@webassemblyjs/wast-printer@1.2.8(transitive)
- Removedwebassemblyjs@1.2.8(transitive)
Updated@webassemblyjs/ast@1.3.0