@tybys/wasm-util 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -456,7 +456,14 @@ export class WASI {
456
456
  return WasiErrno.EINVAL;
457
457
  }
458
458
  buf_len = Number(buf_len);
459
- const { HEAPU8 } = getMemory(this);
459
+ const { HEAPU8, view } = getMemory(this);
460
+ if ((typeof SharedArrayBuffer === 'function' && HEAPU8.buffer instanceof SharedArrayBuffer) ||
461
+ (Object.prototype.toString.call(HEAPU8.buffer) === '[object SharedArrayBuffer]')) {
462
+ for (let i = buf; i < buf + buf_len; ++i) {
463
+ view.setUint8(i, Math.floor(Math.random() * 256));
464
+ }
465
+ return WasiErrno.ESUCCESS;
466
+ }
460
467
  let pos;
461
468
  const stride = 65536;
462
469
  for (pos = 0; pos + stride < buf_len; pos += stride) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tybys/wasm-util",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "description": "WASI polyfill for browser and some wasm util",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./dist/wasm-util.esm-bundler.js",