Socket
Socket
Sign inDemoInstall

@webassemblyjs/ast

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webassemblyjs/ast - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

30

lib/traverse.js

@@ -11,2 +11,12 @@ "use strict";

var partialEvaluation = require("webassemblyjs/lib/interpreter/partial-evaluation");
var _require = require("webassemblyjs/lib/interpreter/runtime/values/memory"),
Memory = _require.Memory;
var _require2 = require("webassemblyjs/lib/interpreter/kernel/memory"),
createAllocator = _require2.createAllocator;
var t = require("./index");
function removeNodeInBody(node, fromNode) {

@@ -54,2 +64,19 @@ switch (fromNode.type) {

function evaluate(customNode) {
var n = [node];
if (typeof customNode !== "undefined") {
n = customNode;
}
var memory = new Memory({
initial: 100
});
var allocator = createAllocator(memory);
var code = n; // $FlowIgnore
code.push(t.instruction("end"));
return partialEvaluation.evaluate(allocator, code);
}
return {

@@ -59,3 +86,4 @@ node: node,

replaceWith: replaceWith,
remove: remove
remove: remove,
evaluate: evaluate
};

@@ -62,0 +90,0 @@ }

6

package.json
{
"name": "@webassemblyjs/ast",
"version": "1.2.3",
"version": "1.2.4",
"description": "AST utils for webassemblyjs",

@@ -14,4 +14,4 @@ "keywords": [

"dependencies": {
"@webassemblyjs/wast-parser": "1.2.3",
"webassemblyjs": "1.2.3"
"@webassemblyjs/wast-parser": "1.2.4",
"webassemblyjs": "1.2.4"
},

@@ -18,0 +18,0 @@ "repository": {

@@ -25,2 +25,21 @@ # @webassemblyjs/ast

### Traverse and partial evaluation
```js
import { traverse } from "@webassemblyjs/ast";
traverse(ast, {
Func(path) {
const res = path.evaluate();
}
});
// Or by specified an array of node
traverse(ast, {
Global(path) {
const res = path.evaluate(path.node.init);
}
});
```
### Instruction signatures

@@ -27,0 +46,0 @@

// @flow
const partialEvaluation = require("webassemblyjs/lib/interpreter/partial-evaluation");
const {
Memory
} = require("webassemblyjs/lib/interpreter/runtime/values/memory");
const {
createAllocator
} = require("webassemblyjs/lib/interpreter/kernel/memory");
const t = require("./index");
type Cb = (type: string, path: NodePath<Node>) => void;

@@ -45,2 +55,19 @@

function evaluate(customNode: ?Array<Node>): ?StackLocal {
let n = [node];
if (typeof customNode !== "undefined") {
n = customNode;
}
const memory = new Memory({ initial: 100 });
const allocator = createAllocator(memory);
const code = n;
// $FlowIgnore
code.push(t.instruction("end"));
return partialEvaluation.evaluate(allocator, code);
}
return {

@@ -51,3 +78,4 @@ node,

replaceWith,
remove
remove,
evaluate
};

@@ -54,0 +82,0 @@ }

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