array is an abv, views

This commit is contained in:
dcode
2019-05-25 14:40:13 +02:00
parent 6d6ed710e5
commit 968192f99b
18 changed files with 90 additions and 53 deletions

View File

@ -41,9 +41,12 @@ assert.strictEqual(module.__getString(module.COLOR), "red");
let ref = module.__retain(module.__allocArray(module.INT32ARRAY_ID, arr));
assert(module.__instanceof(ref, module.INT32ARRAY_ID));
// should be able to get a view on an internal typed array
// should be able to get the values of an array
assert.deepEqual(module.__getArray(ref), arr);
// should be able to get a view on an array
assert.deepEqual(module.__getArrayView(ref), new Int32Array(arr));
// should be able to sum up its values
assert.strictEqual(module.sum(ref), arr.reduce((a, b) => (a + b) | 0, 0) | 0);