From 7c7f241fb1a546979a14910b0a9b3011e4476392 Mon Sep 17 00:00:00 2001 From: Jason Mulligan <jason.mulligan@avoidwork.com> Date: Tue, 29 Sep 2015 20:18:41 -0400 Subject: [PATCH] Updating README --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index f15710e..aa7faba 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,27 @@ This is non-functional, it's just a place holder for 1.0.0! [](http://travis-ci.org/avoidwork/tiny-worker) ## Example +#### Creating a Worker from a file +The worker script: +```javascript +self.onmessage = function (ev) { + postMessage(ev.data); +}; +``` + +The core script: +```javascript +var Worker = require("tiny-worker"); +var worker = new Worker("repeat.js"); + +worker.onmessage = function (ev) { + console.log(ev.data); + worker.terminate(); +}; + +worker.postMessage("Hello World!"); + +#### Creating a Worker from a Function ```javascript var Worker = require("tiny-worker"); var worker = new Worker(function () { -- GitLab