fix linting, add to readme

This commit is contained in:
Ben 2020-09-28 00:45:56 -07:00
parent d184681eae
commit 6bcb3afb38
2 changed files with 23 additions and 19 deletions

View File

@ -9,6 +9,7 @@ Install
```
npm i vcd-stream
make wasm
```
Require

View File

@ -1,5 +1,7 @@
'use strict';
/* global BigInt */
const dotProp = require('dot-prop');
function _waitForStart(mod) {
@ -51,7 +53,7 @@ module.exports = () => {
}
bindCWrap();
bindCallback();
}
};
// gets a string from a c heap pointer and length
const getString = (name, len) => {
@ -62,7 +64,7 @@ module.exports = () => {
string += String.fromCharCode(view[i]);
}
return string;
}
};
let boundInfo;
@ -83,6 +85,7 @@ module.exports = () => {
boundSet = wasm.addFunction(function(name, len, type, v0, v1) {
let prop = getString(name, len);
let tmp;
switch(type) {
// set number
@ -102,7 +105,7 @@ module.exports = () => {
break;
// path to path (any type)
case 3:
let tmp = dotProp.get(boundInfo, getString(v0, v1));
tmp = dotProp.get(boundInfo, getString(v0, v1));
// console.log(`for ${getString(v0, v1)} got ${tmp}, set to ${prop}`);
dotProp.set(boundInfo, prop, tmp);
break;
@ -121,7 +124,7 @@ module.exports = () => {
boundGet = wasm.addFunction(function(name, len) {
let prop = getString(name, len);
return 42;
return prop;
}, 'iii');
@ -140,12 +143,12 @@ module.exports = () => {
const view0 = wasm.HEAPU8.subarray(value, value+(valueWords*8));
const view1 = wasm.HEAPU8.subarray(mask, mask+(valueWords*8));
let big_value = u8ToBn(view0);
let big_mask = u8ToBn(view1);
let bigValue = u8ToBn(view0);
let bigMask = u8ToBn(view1);
// console.log(big_value.toString(16));
// console.log(bigValue.toString(16));
ee[1](name, time, command, big_value, big_mask);
ee[1](name, time, command, bigValue, bigMask);
}, 'viiiiiii');
};
@ -158,6 +161,7 @@ module.exports = () => {
ee[0] = cb0;
ee[1] = cb1;
context = c.init(boundEE0, boundEE1, boundSet, boundGet);
return context;
},
execute: (ctx, cb0, cb1, info, chunk) => {
boundInfo = info;
@ -170,7 +174,6 @@ module.exports = () => {
},
getTime: (ctx) => {
return BigInt(c.getTime(ctx));
},
time: () => total + start
}
};
};