-
Notifications
You must be signed in to change notification settings - Fork 106
/
verb.js
44 lines (31 loc) · 1.02 KB
/
verb.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Index / Entry point for the VERB-NURBS package.
*/
// provide window as required by the promhx library
if (typeof window === "undefined") {
var window = global;
}
// setup the promise handling for async method invocations
const lookup = function(className, methodName){
var obj = { verb: verb };
className.split(".").forEach(function(x){
if (obj) obj = obj[ x ];
});
if (!obj) return null;
return obj[ methodName ];
}
const onmessage = function( e ) {
if (!e.data || !e.data.className || !e.data.methodName) return;
const method = lookup( e.data.className, e.data.methodName );
if (!method){
return console.error("could not find " + e.data.className + "." + e.data.methodName)
}
postMessage( { result: method.apply( null, e.data.args ), id: e.data.id } );
}
// provide the Worker class for async library functions
if (typeof Worker === "undefined") {
var Worker = require("web-worker")
}
// import and re-export the Javascript library
const verb = require('./verbHaxe.js');
module.exports = verb