New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

walt-compiler

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

walt-compiler - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

.nyc_output/3fa8ddc0146aa8f31e50ede2e8a9a82a.json

2

package.json
{
"name": "walt-compiler",
"version": "0.3.2",
"version": "0.3.3",
"description": "Alternative syntax for WebAssembly text format",

@@ -5,0 +5,0 @@ "main": "dist/walt.js",

@@ -10,6 +10,9 @@ # Walt Compiler

Compile and run Walt code in browser:
```js
import compileWalt, { debug as printWasm } from 'walt-compiler';
import compileWalt from 'walt-compiler';
const buffer = compileWalt(`
let counter: i32 = 0;
export function count(): i32 {

@@ -21,7 +24,25 @@ counter += 1;

WebAssembly.instantiate(buffer).then(module => {
console.log(`Counter export: ${module.instance.exports.count()}`);
WebAssembly.instantiate(buffer).then(result => {
console.log(`First invocation: ${result.instance.exports.count()}`);
console.log(`Second invocation: ${result.instance.exports.count()}`);
});
```
Compile and save a `.wasm` file via Node.js:
```js
const compileWalt = require('walt-compiler').default;
const fs = require('fs');
const buffer = compileWalt(`
let counter: i32 = 0;
export function count(): i32 {
counter += 1;
return counter;
}
`);
fs.writeFileSync('bin.wasm', new Uint8Array(buffer));
```
#### parse

@@ -34,5 +55,5 @@

```js
import { parse } from 'walt-compiler';
import { parser } from 'walt-compiler';
const ast = parse(`
const ast = parser(`
type MyObjectType = { 'foo': i32, 'bar': f32 };

@@ -39,0 +60,0 @@ export function test(): f32 {

@@ -386,4 +386,4 @@ # Snapshot report for `src/__tests__/function-spec.js`

0000017e: 41 ; i32.const ␊
0000017f: 4 ; i32.literal␊
00000180: 6c ; i32.mul ␊
0000017f: 2 ; i32.literal␊
00000180: 74 ; i32.shl ␊
00000181: 6a ; i32.add ␊

@@ -398,4 +398,4 @@ 00000182: 28 ; i32.load ␊

00000189: 41 ; i32.const ␊
0000018a: 4 ; i32.literal␊
0000018b: 6c ; i32.mul ␊
0000018a: 2 ; i32.literal␊
0000018b: 74 ; i32.shl ␊
0000018c: 6a ; i32.add ␊

@@ -421,4 +421,4 @@ 0000018d: 28 ; i32.load ␊

0000019f: 41 ; i32.const ␊
000001a0: 4 ; i32.literal␊
000001a1: 6c ; i32.mul ␊
000001a0: 2 ; i32.literal␊
000001a1: 74 ; i32.shl ␊
000001a2: 6a ; i32.add ␊

@@ -435,4 +435,4 @@ 000001a3: 41 ; i32.const ␊

000001ac: 41 ; i32.const ␊
000001ad: 4 ; i32.literal␊
000001ae: 6c ; i32.mul ␊
000001ad: 2 ; i32.literal␊
000001ae: 74 ; i32.shl ␊
000001af: 6a ; i32.add ␊

@@ -439,0 +439,0 @@ 000001b0: 41 ; i32.const ␊

@@ -263,4 +263,4 @@ # Snapshot report for `src/__tests__/object-literal-spec.js`

00000102: 41 ; i32.const ␊
00000103: 4 ; i32.literal␊
00000104: 6c ; i32.mul ␊
00000103: 2 ; i32.literal␊
00000104: 74 ; i32.shl ␊
00000105: 6a ; i32.add ␊

@@ -277,4 +277,4 @@ 00000106: 41 ; i32.const ␊

0000010f: 41 ; i32.const ␊
00000110: 4 ; i32.literal␊
00000111: 6c ; i32.mul ␊
00000110: 2 ; i32.literal␊
00000111: 74 ; i32.shl ␊
00000112: 6a ; i32.add ␊

@@ -291,4 +291,4 @@ 00000113: 41 ; i32.const ␊

0000011c: 41 ; i32.const ␊
0000011d: 4 ; i32.literal␊
0000011e: 6c ; i32.mul ␊
0000011d: 2 ; i32.literal␊
0000011e: 74 ; i32.shl ␊
0000011f: 6a ; i32.add ␊

@@ -295,0 +295,0 @@ 00000120: 41 ; i32.const ␊

@@ -27,3 +27,5 @@ import test from "ava";

let baz: i32 = 0;
let x: i32;
export function test(): i32 {
x = 1;
foo = two();

@@ -30,0 +32,0 @@ baz = alsoTwo();

@@ -18,4 +18,4 @@ // @flow

// TODO: fix this for user-defined types
{ kind: opcode.i32Const, params: [4] },
{ kind: opcode.i32Mul, params: [] },
{ kind: opcode.i32Const, params: [2] },
{ kind: opcode.i32Shl, params: [] },
]);

@@ -22,0 +22,0 @@ type = isArray.payload;

@@ -8,12 +8,15 @@ // @flow

const _global = generateValueType(node);
const { value } = node.params[0];
switch (_global.type) {
case F32:
case F64:
_global.init = parseFloat(value);
break;
case I32:
case I64:
default:
_global.init = parseInt(value);
const [initializer] = node.params;
if (initializer != null) {
const { value } = initializer;
switch (_global.type) {
case F32:
case F64:
_global.init = parseFloat(value);
break;
case I32:
case I64:
default:
_global.init = parseInt(value);
}
}

@@ -20,0 +23,0 @@

@@ -21,4 +21,4 @@ // @flow

// TODO: fix this for user-defined types
{ kind: opcode.i32Const, params: [4] },
{ kind: opcode.i32Mul, params: [] },
{ kind: opcode.i32Const, params: [2] },
{ kind: opcode.i32Shl, params: [] },
]);

@@ -25,0 +25,0 @@ type = isArray.payload;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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