Skip to content

Commit 9d38e46

Browse files
committed
Merge branch 'master' of github.com:constantinius/geotiff.js
2 parents acf222a + f4f1939 commit 9d38e46

File tree

5 files changed

+36
-10
lines changed

5 files changed

+36
-10
lines changed

package-lock.json

Lines changed: 25 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@
4747
"npm-run-all": "^4.1.5",
4848
"parcel-bundler": "^1.12.4",
4949
"parcel-plugin-bundle-visualiser": "^1.2.0",
50+
"rimraf": "^3.0.2",
5051
"serve-static": "^1.14.1"
5152
},
5253
"scripts": {
5354
"build": "npm run build:clean; run-p build:browser build:node;",
54-
"build:clean": "rm -rf dist-node/ dist-browser/",
55+
"build:clean": "rimraf dist-node/ dist-browser/",
5556
"build:node": "parcel build src/geotiff.js --target node --out-dir dist-node/",
5657
"build:browser": "parcel build src/geotiff.js --target browser --out-dir dist-browser/ --global GeoTIFF --public-url .",
5758
"watch:browser": "parcel watch src/geotiff.js --target browser --out-dir dist-browser/ --global GeoTIFF --public-url .",

src/compression/basedecoder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { applyPredictor } from '../predictor';
22

33
export default class BaseDecoder {
4-
decode(fileDirectory, buffer) {
5-
const decoded = this.decodeBlock(buffer);
4+
async decode(fileDirectory, buffer) {
5+
const decoded = await this.decodeBlock(buffer);
66
const predictor = fileDirectory.Predictor || 1;
77
if (predictor !== 1) {
88
const isTiled = !fileDirectory.StripOffsets;

src/decoder.worker.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { expose, Transfer } from 'threads/worker';
22
import { getDecoder } from './compression';
33

4-
function decode(fileDirectory, buffer) {
4+
async function decode(fileDirectory, buffer) {
55
const decoder = getDecoder(fileDirectory);
6-
return Transfer(decoder.decode(fileDirectory, buffer));
6+
const decoded = await decoder.decode(fileDirectory, buffer);
7+
return Transfer(decoded);
78
}
89

910
expose(decode);

src/pool.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ class Pool {
1515
* @param {Number} size The size of the pool. Defaults to the number of CPUs
1616
* available. When this parameter is `null` or 0, then the
1717
* decoding will be done in the main thread.
18+
* @param {Worker} worker The decoder worker, loaded and initialised. Enables
19+
* loading the worker using worker-loader(or others) externally
20+
* when using this library as a webpack dependency.
1821
*/
19-
constructor(size = defaultPoolSize) {
20-
const worker = new Worker('./decoder.worker.js');
22+
constructor(size = defaultPoolSize, worker = new Worker('./decoder.worker.js')) {
2123
this.pool = tPool(() => spawn(worker), size);
2224
}
2325

0 commit comments

Comments
 (0)