Skip to content

Commit

Permalink
Merge pull request #23 from biowasm/feature/22-feature-detection
Browse files Browse the repository at this point in the history
Add feature detection
  • Loading branch information
robertaboukhalil authored Jul 15, 2021
2 parents 63ced6c + 5df65a9 commit f7ed43a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions aioli.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ class Aioli
const workerResponse = await fetch(this.config.urlAioli);
const workerJS = await workerResponse.text();

// Feature detection using the module's config.json file
try {
const workerConfig = await fetch(`${this.config.urlModule}/config.json`).then(d => d.json());
// Check for SIMD support (source: <https://github.com/GoogleChromeLabs/wasm-feature-detect>)
if(workerConfig["wasm-features"].includes("simd") && !WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])))
this.config.program += "-nosimd";
} catch (error) { }

// Load compiled .wasm module JS
const moduleResponse = await fetch(`${this.config.urlModule}/${this.config.program}.js`);
const moduleJS = await moduleResponse.text();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@biowasm/aioli",
"version": "1.4.1",
"version": "1.5.0",
"description": "A framework for building WebAssembly-based genomics tools",
"main": "aioli.js",
"repository": {
Expand Down

0 comments on commit f7ed43a

Please sign in to comment.