image-filter-core
Advanced tools
Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "image-filter-core", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Core module for image-filter", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -53,7 +53,7 @@ require('es6-promise/auto'); | ||
*/ | ||
function createWorker() { | ||
function createWorkerURL() { | ||
var functionBody = extractBodyFunction(worker); | ||
var blob = new Blob([functionBody], { type: 'text/javascript' }); | ||
return new Worker(window.URL.createObjectURL(blob)); | ||
return window.URL.createObjectURL(blob); | ||
} | ||
@@ -84,5 +84,4 @@ | ||
function apply(data, transform, options, nWorkers) { | ||
var w = createWorker(); | ||
var transformationURL = createTransformation(transform); | ||
var workerURL = createWorkerURL(); | ||
var canvas = getCanvas(data.width, data.height); | ||
@@ -108,2 +107,3 @@ var context = canvas.getContext('2d'); | ||
for (var index = 0; index < nWorkers; index++) { | ||
var w = new Worker(workerURL); | ||
@@ -113,3 +113,2 @@ w.addEventListener('message', function (e) { | ||
var resultCanvasData = e.data.result; | ||
var index = e.data.index; | ||
@@ -119,3 +118,3 @@ // Copying back canvas data to canvas | ||
// If the second webworker (index 1) returns data, apply it at pixel (0, canvas.height/4) onwards, and so on | ||
context.putImageData(resultCanvasData, 0, blockSize * index); | ||
context.putImageData(resultCanvasData, 0, blockSize * e.data.index); | ||
@@ -122,0 +121,0 @@ finished++; |
@@ -90,4 +90,4 @@ const expect = require('chai').expect; | ||
// Two object urls created, one for the worker one for the transform function | ||
expect(window.URL.createObjectURL.calledTwice).to.equal(true); | ||
expect(window.Worker.calledOnce).to.equal(true); | ||
expect(window.URL.createObjectURL.callCount).to.equal(2); | ||
expect(window.Worker.callCount).to.equal(4); | ||
@@ -94,0 +94,0 @@ const evt = { data: { result: 'DUMMY', index: 1 } }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package