primea-annotations
Advanced tools
Comparing version 0.0.0 to 0.0.1
40
index.js
const Stream = require('buffer-pipe') | ||
const Buffer = require('safe-buffer').Buffer | ||
const leb = require('leb128') | ||
const {findSections} = require('wasm-json-toolkit') | ||
const FUNC_TYPE = 0x60 | ||
const LANGUAGE_TYPES_STRG = { | ||
@@ -10,10 +12,9 @@ 'i32': 0x7f, | ||
'f64': 0x7c, | ||
'anyref': 0x70, | ||
'module': 0x6f, | ||
'data': 0x6e, | ||
'elem': 0x6d, | ||
'link': 0x6c, | ||
'id': 0x6b, | ||
'func': 0x60 | ||
'func': 0x6e, | ||
'data': 0x6d, | ||
'elem': 0x6c, | ||
'link': 0x6b, | ||
'id': 0x6a | ||
} | ||
@@ -26,10 +27,9 @@ | ||
0x7c: 'f64', | ||
0x70: 'anyref', | ||
0x6f: 'module', | ||
0x6e: 'data', | ||
0x6d: 'elem', | ||
0x6c: 'link', | ||
0x6b: 'id', | ||
0x60: 'func' | ||
0x6e: 'func', | ||
0x6d: 'data', | ||
0x6c: 'elem', | ||
0x6b: 'link', | ||
0x6a: 'id' | ||
} | ||
@@ -180,3 +180,3 @@ | ||
// a single type entry binary encoded | ||
binEntries.write([LANGUAGE_TYPES_STRG[entry.form]]) // the form | ||
binEntries.write([FUNC_TYPE]) | ||
@@ -209,3 +209,3 @@ const len = entry.params.length // number of parameters | ||
let type = stream.read(1)[0] | ||
if (type !== 0x60) { | ||
if (type !== FUNC_TYPE) { | ||
throw new Error('invalid form') | ||
@@ -255,3 +255,7 @@ } | ||
const body = wasm.subarray(8) | ||
return Buffer.concat([preramble, custom, body]) | ||
return Buffer.concat([ | ||
Buffer.from(preramble), | ||
Buffer.from(custom), | ||
Buffer.from(body) | ||
]) | ||
} | ||
@@ -261,4 +265,4 @@ | ||
* encodes a json definition and injects it into a wasm binary | ||
* @param {Object} annotation - the type definition | ||
* @param {Buffer} wasm - the wasm binary to inject | ||
* @param {Object} annotation - the type definition | ||
*/ | ||
@@ -346,3 +350,5 @@ function encodeAndInject (annotation, wasm) { | ||
encode, | ||
mergeTypeSections | ||
mergeTypeSections, | ||
LANGUAGE_TYPES_BIN, | ||
LANGUAGE_TYPES_STRG | ||
} |
{ | ||
"name": "primea-annotations", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "parsing/encoding for primea's type annotations", | ||
@@ -20,4 +20,5 @@ "main": "index.js", | ||
"buffer-pipe": "0.0.2", | ||
"wasm-json-toolkit": "^0.2.3", | ||
"leb128": "0.0.4" | ||
"leb128": "0.0.4", | ||
"safe-buffer": "^5.1.1", | ||
"wasm-json-toolkit": "^0.2.3" | ||
}, | ||
@@ -24,0 +25,0 @@ "devDependencies": { |
# SYNOPSIS | ||
[![NPM Package](https://img.shields.io/npm/v/primea-annotations.svg?style=flat-square)](https://www.npmjs.org/package/primea-annotations) | ||
@@ -3,0 +4,0 @@ [![Build Status](https://img.shields.io/travis/primea/js-primea-annotations.svg?branch=master&style=flat-square)](https://travis-ci.org/primea/js-primea-annotations) |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
1719416
33
17150
46
4
1
+ Addedsafe-buffer@^5.1.1