Created
July 27, 2017 00:48
-
-
Save lisp-ceo/03a2fc316e59515a06241f9d6b804ebf to your computer and use it in GitHub Desktop.
What the fuck is this language even?
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 characters
| #!/usr/bin/env node | |
| let success = 'success'; | |
| let failure = 'failure'; | |
| async function runEngine() { | |
| console.log('runEngine'); | |
| var report = await run1(); | |
| return report; // Important! Otherwise it will return some bizarre object | |
| // { '0': {}, | |
| // '1': | |
| // { [Function: require] | |
| // resolve: [Function: resolve], | |
| // main: | |
| // Module { | |
| // id: '.', | |
| // exports: {}, | |
| // parent: null, | |
| // filename: '/Users/htmldrum/code/javascript/engine.js', | |
| // loaded: true, | |
| // children: [], | |
| // paths: [Array] }, | |
| // extensions: { '.js': [Function], '.json': [Function], '.node': [Function] }, | |
| // cache: { '/Users/htmldrum/code/javascript/engine.js': [Object] } }, | |
| // '2': | |
| // Module { | |
| // id: '.', | |
| // exports: {}, | |
| // parent: null, | |
| // filename: '/Users/htmldrum/code/javascript/engine.js', | |
| // loaded: true, | |
| // children: [], | |
| // paths: | |
| // [ '/Users/htmldrum/code/javascript/node_modules', | |
| // '/Users/htmldrum/code/node_modules', | |
| // '/Users/htmldrum/node_modules', | |
| // '/Users/node_modules', | |
| // '/node_modules' ] }, | |
| // '3': '/Users/htmldrum/code/javascript/engine.js', | |
| // '4': '/Users/htmldrum/code/javascript' } | |
| }; | |
| function run1() { | |
| return new Promise((resolve, reject) => { | |
| setTimeout(() => { | |
| console.log("run1: resolved"); | |
| resolve(success); | |
| // callcbSucc(resolve); | |
| }, 500); | |
| }); | |
| } | |
| function run2() { | |
| console.log("run2"); | |
| return new Promise((resolve, reject) => { | |
| }); | |
| } | |
| function run3() { | |
| console.log("run3"); | |
| return new Promise((resolve, reject) => { | |
| }); | |
| } | |
| function run4() { | |
| console.log("run4"); | |
| return new Promise((resolve, reject) => { | |
| }); | |
| } | |
| function callcbSucc(fn) { | |
| fn('titties'); | |
| } | |
| function callcbFail(fn) { | |
| fn(failure); | |
| } | |
| runEngine() | |
| .then(x => { | |
| console.log("Arguments: ", arguments); | |
| console.log("Resolved with: ", x); | |
| }).catch(reason => { | |
| console.log("Failed with reason: ", arguments); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment