Last active
March 14, 2016 21:43
-
-
Save joesavage/5714fa5c1fb2ad63a2c3 to your computer and use it in GitHub Desktop.
This file contains 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
(function() { | |
var desiredInput = "success"; | |
var insertChar = (function(i, self) { | |
userInput.push(desiredInput.charCodeAt(i)); | |
Module.resume("char_ready"); | |
if (i < desiredInput.length) { | |
return setTimeout((function() { self(i + 1, self) }), Math.floor(Math.random() * 1500)); | |
} | |
}); | |
insertChar(0, insertChar); | |
})(); |
This file contains 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
var userInput = []; | |
var Module = { stdin: (function() { return userInput.shift() || null; }) }; |
This file contains 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
#include <stdio.h> | |
#include <emscripten.h> | |
#define INPUT_LENGTH 7 | |
int main(int argc, char **argv) { | |
char input[INPUT_LENGTH] = {}; | |
for (int n = 0; n < INPUT_LENGTH; ++n) { | |
emscripten_suspend("char_ready"); | |
input[n] = getchar(); | |
printf("%c\n", input[n]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment