@aml-org/amf-custom-validator-web 0.1.0-SNAPSHOT.-WebPack.1 → 0.1.0-SNAPSHOT.WebPack.2

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.
@@ -0,0 +1,10 @@
1
+ /*!
2
+ * The buffer module from node.js, for the browser.
3
+ *
4
+ * @author Feross Aboukhadijeh <https://feross.org>
5
+ * @license MIT
6
+ */
7
+
8
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
9
+
10
+ /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@aml-org/amf-custom-validator-web",
3
- "version": "0.1.0-SNAPSHOT.-WebPack.1",
3
+ "version": "0.1.0-SNAPSHOT.WebPack.2",
4
4
  "description": "AMF validator backed by OPA Rego",
5
- "main": "index.js",
5
+ "main": "dist/main.js",
6
6
  "scripts": {
7
7
  "test": "mocha -t 10000",
8
8
  "build:dist": "webpack --config ./webpack.config.js"
package/index.js DELETED
@@ -1,48 +0,0 @@
1
- require(__dirname + "/lib/wasm_exec");
2
- const pako = require("pako");
3
- let wasm_gz = require("/lib/main.wasm.gz")
4
- let wasm
5
-
6
- let INIT = false
7
- let go = new Go();
8
-
9
- const run = function(profile, data, debug) {
10
- let before = new Date()
11
- const res = __AMF__validateCustomProfile(profile,data, debug);
12
- let after = new Date();
13
- if (debug) console.log("Elapsed : " + (after - before))
14
- return res;
15
- }
16
-
17
- const validateCustomProfile = function(profile, data, debug, cb) {
18
- if (INIT) {
19
- let res = run(profile, data, debug);
20
- cb(res,null);
21
- } else {
22
- if(!wasm_gz || !wasm) {
23
- wasm = pako.ungzip(Buffer.from(wasm_gz, 'base64'))
24
- }
25
- if (WebAssembly) {
26
- WebAssembly.instantiate(wasm, go.importObject).then((result) => {
27
- go.run(result.instance);
28
- INIT = true;
29
- let res = run(profile, data, debug);
30
- cb(res,null);
31
- });
32
- } else {
33
- cb(null,new Error("WebAssembly is not supported in your JS environment"));
34
- }
35
- }
36
- }
37
-
38
- const exit = function() {
39
- if(INIT) {
40
- __AMF__terminateValidator()
41
- go.exit(0)
42
- INIT = false;
43
- go = new Go();
44
- }
45
- }
46
-
47
- module.exports.validate = validateCustomProfile;
48
- module.exports.exit = exit;