From c7c22e3db1c826bcfb2bc66651ec480aae0d4ae0 Mon Sep 17 00:00:00 2001 From: yo mama Date: Sat, 4 Apr 2015 01:00:59 -0700 Subject: first --- node_modules/webworker-threads/examples/ex04_worker.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 node_modules/webworker-threads/examples/ex04_worker.js (limited to 'node_modules/webworker-threads/examples/ex04_worker.js') diff --git a/node_modules/webworker-threads/examples/ex04_worker.js b/node_modules/webworker-threads/examples/ex04_worker.js new file mode 100644 index 0000000..4a784e6 --- /dev/null +++ b/node_modules/webworker-threads/examples/ex04_worker.js @@ -0,0 +1,15 @@ +/// !example +/// ## Loading the worker code from a file (worker side) +/// +/// This file contains the pong (worker) side of our ping pong example. +/// It is loaded by a `t.load` call in `ex4_main.js`. +function fibo(n) { + return n > 1 ? fibo(n - 1) + fibo(n - 2) : 1; +} + +// returning the next fibonacci number when a 'next' event comes in: +var i = 1; +thread.on('next', function() { + thread.emit('data', i, fibo(i)); + i++; +}); \ No newline at end of file -- cgit v1.2.3-70-g09d2