multimath
Advanced tools
Comparing version 1.0.3 to 2.0.0
@@ -0,1 +1,9 @@ | ||
2.0.0 / 2019-07-15 | ||
------------------ | ||
- Change `has_wasm` to support lazy evaluation. This prevents possible browser | ||
CSP report when feature is not requested in options, #6. | ||
- Dev deps bump. | ||
1.0.3 / 2018-03-05 | ||
@@ -2,0 +10,0 @@ ------------------ |
14
index.js
@@ -23,3 +23,2 @@ 'use strict'; | ||
this.__cache = {}; | ||
this.has_wasm = hasWebAssembly(); | ||
@@ -39,2 +38,5 @@ this.__init_promise = null; | ||
MultiMath.prototype.has_wasm = hasWebAssembly; | ||
MultiMath.prototype.use = function (module) { | ||
@@ -44,6 +46,6 @@ this.__modules[module.name] = module; | ||
// Pin the best possible implementation | ||
if (!this.has_wasm || !this.options.wasm || !module.wasm_fn) { | ||
if (this.options.wasm && this.has_wasm() && module.wasm_fn) { | ||
this[module.name] = module.wasm_fn; | ||
} else { | ||
this[module.name] = module.fn; | ||
} else { | ||
this[module.name] = module.wasm_fn; | ||
} | ||
@@ -58,3 +60,3 @@ | ||
if (!this.options.js && this.options.wasm && !this.has_wasm) { | ||
if (!this.options.js && this.options.wasm && !this.has_wasm()) { | ||
return Promise.reject(new Error('mathlib: only "wasm" was enabled, but it\'s not supported')); | ||
@@ -68,3 +70,3 @@ } | ||
if (!self.has_wasm || !self.options.wasm || !module.wasm_fn) return null; | ||
if (!self.options.wasm || !self.has_wasm() || !module.wasm_fn) return null; | ||
@@ -71,0 +73,0 @@ // If already compiled - exit |
{ | ||
"name": "multimath", | ||
"description": "Core to create fast image math in WebAssembly and JS.", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"keywords": [ | ||
@@ -27,6 +27,8 @@ "webassembly", | ||
"benchmark": "^2.1.0", | ||
"eslint": "^4.8.0", | ||
"mocha": "^4.0.1", | ||
"nyc": "^11.2.1" | ||
"eslint": "^6.0.1", | ||
"mocha": "^6.1.4", | ||
"nyc": "^14.1.1", | ||
"proxyquire": "^2.1.1", | ||
"sinon": "^7.3.2" | ||
} | ||
} |
62743
6