Skip to content

Commit a6fdfec

Browse files
author
fresa
committed
Made sure the dist file does not contain test code. The dist code does not have the version in the name. Added a main script file in the bower.json
1 parent 9118aea commit a6fdfec

File tree

6 files changed

+12
-53
lines changed

6 files changed

+12
-53
lines changed

Gruntfile.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ module.exports = function (grunt) {
3636
},
3737
concat: {
3838
src: {
39-
src: ['src/**/*.js'],
40-
dest: 'dist/angular-workers-<%= pkg.version %>.js'
39+
src: ['src/angular-workers.js'],
40+
dest: 'dist/angular-workers.js'
4141
}
4242
},
4343
uglify: {
4444
src: {
4545
files: {
46-
'dist/angular-workers-<%= pkg.version %>.min.js': '<%= concat.src.dest %>'
46+
'dist/angular-workers.min.js': '<%= concat.src.dest %>'
4747
}
4848
}
4949
},

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
> A wrapper for web workers in angular
44
5-
##Why?
5+
###Why?
66
Using web workers is somewhat awkward in raw Javascript. Doing it in angular applications even more so.
77
Each web worker runs in it's own context, and this context is isolated from the angular application.
88

9-
##What does angular-workers do
9+
###What does angular-workers do
1010
angular-workers provides an angular service which upon request creates a web worker.
1111
The returned web worker runs it's own angular context which allows it to resolve angular dependencies.
1212

1313
##How to use
14+
1415
1. Depend on the WorkerService.
1516
2. Specify the URL to the file containing the angular script by invoking:
1617
<pre><code>
@@ -61,9 +62,9 @@ The browser running the angular service needs to support the following:
6162
##Limitations
6263
The angular-workers is a wrapper around standard web workers. So all limitations with web workers apply.
6364
* Data sent between the worker and main thread is deep cloned. (angular-workers does not use transferable objects, yet)
64-
This means transferring large object (about >20Mb, [Communicating Large Objects with Web Workers in javascript, Samuel Mendenhall](http://developerblog.redhat.com/2014/05/20/communicating-large-objects-with-web-workers-in-javascript/))
65-
will cause noticeable delays. Samuel Mendenhall recommends sending the data in chunks. This can be achieved using the notify
66-
in the angular promise.
65+
This means transferring large object (about >20Mb, [Communicating Large Objects with Web Workers in javascript, Samuel Mendenhall](http://developerblog.redhat.com/2014/05/20/communicating-large-objects-with-web-workers-in-javascript/))
66+
will cause noticeable delays. Samuel Mendenhall recommends sending the data in chunks. This can be achieved using the notify
67+
in the angular promise.
6768
* There is no DOM in the worker. Other things are missing as well. No global "document" object. The bare minimum of these
6869
have been mocked to allow angular to start in the worker.
6970
* The web worker share no runtime data with the main thread. This is great since it prevents deadlock, starvation and many

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"author": "Fredrik Sandell",
33
"name": "angular-workers",
44
"description": "Web workers wrapper for angular",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
6+
"main": "./dist/angular-workers.js",
67
"homepage": "http://github.com/FredrikSandell/angular-workers",
78
"repository": {
89
"type": "git",

dist/angular-workers-1.0.0.min.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/angular-workers-1.0.0.js renamed to dist/angular-workers.js

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,3 @@
1-
angular.module('FredrikSandell.worker-pool-pi-calculator', []).service('PiCalculatorService', [
2-
'$q',
3-
function ($q) {
4-
var that = {};
5-
/**
6-
* If this is done correctly really doesn't matter. What we need is a long running task which hogs CPU-time.
7-
* Number of decimals to calculate for PI
8-
* @param num
9-
*/
10-
that.calculatePi = function (num) {
11-
var deferred = $q.defer();
12-
var pi = 4, top = 4, bot = 3, minus = true;
13-
var startTime = Date.now();
14-
var somewhatExactPi = next(pi, top, bot, minus, num, deferred);
15-
deferred.resolve({
16-
pi: somewhatExactPi,
17-
runtime: calculateRuntime(startTime, Date.now())
18-
});
19-
return deferred.promise;
20-
};
21-
function next(pi, top, bot, minus, num, deferred) {
22-
for (var i = 0; i < num; i++) {
23-
pi += minus ? -(top / bot) : top / bot;
24-
minus = !minus;
25-
bot += 2;
26-
if (i % 1000 === 0) {
27-
deferred.notify(pi);
28-
}
29-
}
30-
return pi;
31-
}
32-
function calculateRuntime(start, end) {
33-
var total = end - start;
34-
if (total >= 1000) {
35-
total = total / 1000 + 'seconds';
36-
} else {
37-
total += 'ms';
38-
}
39-
return total;
40-
}
41-
return that;
42-
}
43-
]);
441
angular.module('FredrikSandell.worker-pool', []).service('WorkerService', [
452
'$q',
463
function ($q) {

dist/angular-workers.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)