-
-
Save soswow/28547fb866c4236b4ed3 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
f = (n) -> | |
if n is 0 | |
0 | |
else if n is 1 | |
1 | |
else | |
f(n-1) + f(n-2) | |
module.exports = f |
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
ipc = require 'ipc' | |
fib = require './fib' | |
ipc.on 'find-fib', (event, num) -> | |
console.log '2' | |
setTimeout -> | |
console.log '5' | |
event.sender.send 'fib-result', fib(45) | |
, 2000 | |
console.log '3' |
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
ipc = require 'ipc' | |
ipc.on 'fib-result', (result) -> | |
console.log '6' | |
console.log result | |
$ -> | |
$('#fib-start').click -> | |
console.log '1' | |
ipc.send 'find-fib', 45 | |
console.log '4' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment