Created
May 6, 2016 15:40
-
-
Save tshm/1ea30b12ed183e3d5d1f77ffdc6da8a4 to your computer and use it in GitHub Desktop.
Revisions
-
tshm created this gist
May 6, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ /** allow to use Elm from nodejs... */ const vm = require('vm') const fs = require('fs') function log( o ) { console.log( o ) } /** loads Elm compiled javascript * and returns Elm object */ function loadElm( path ) { log('exports called.') const data = fs.readFileSync( path ) const context = { console, setInterval, setTimeout, setImmediate } vm.runInNewContext( data, context, path ) return context.Elm } /** main */ const Elm = loadElm('./elm.js') const app = Elm.worker( Elm.Main, {}) app.ports.time.subscribe(log) log( Elm )