Node + browser-friendly index.ts.

This commit is contained in:
Joshua A. Horton 2018-11-16 09:38:53 +07:00
parent f87bbb4b07
commit e1e22e7bcf

View file

@ -1,4 +1,14 @@
// Dummy module for getting environment setup.
module.exports ={
hello: () => 'hello'
class MyWorker {
public hello() {
return 'hello';
}
}
// The technique below allows code to work both in-browser and in Node.
if(typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = new MyWorker();
} else {
//@ts-ignore
window.worker = new MyWorker();
}