Skip to content

Commit

Permalink
updated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielJDufour committed Jan 17, 2023
1 parent 20d460a commit f150b18
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
11 changes: 7 additions & 4 deletions index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ function createWorker(options) {
const useFrameWorker = typeof options === "object" && options.iframe === true;
const WebWorker = useFrameWorker === false && typeof Worker === "function" ? Worker : FrameWorker;
const maxTiles = typeof options === "object" && typeof options.maxTiles === "number" ? options.maxTiles : Infinity;
const debugLevel = typeof options === "object" && typeof options.debugLevel === "number" ? options.debugLevel : 0;
if (debugLevel >= 1) console.log("[geotiff-tile-web-worker:createWorker] debug level is " + debugLevel);

const blob = new Blob([workerString], { type: "text/javascript" });
const blobURL = URL.createObjectURL(blob);
Expand All @@ -14,7 +16,7 @@ function createWorker(options) {

let tileCount = 0;

const absolutify = (url) => {
const absolutify = url => {
if (url.startsWith("/")) return location.origin + url;

if (url.startsWith("./")) {
Expand All @@ -26,7 +28,7 @@ function createWorker(options) {

const resolvers = {};

worker.onmessage = function (evt) {
worker.addEventListener("message", function (evt) {
const { type, data = {} } = evt.data;

const { id } = data;
Expand All @@ -46,7 +48,7 @@ function createWorker(options) {
} else {
console.error("unknown type " + type);
}
};
});

worker.clearCache = function () {
worker.postMessage({ type: CLEAR_CACHE });
Expand All @@ -60,7 +62,7 @@ function createWorker(options) {
};

worker.createTile = function (params) {
const { debug_level, timeout, url, ...rest } = params;
const { debug_level = 0, timeout, url, ...rest } = params;
if (debug_level >= 1) console.log("[geotiff-tile-web-worker:createTile] starting with:", params);

const id = Math.pow(Math.random(), Math.random()).toString().substring(2);
Expand All @@ -74,6 +76,7 @@ function createWorker(options) {
data: {
id,
url: absolutify(url),
debug_level,
...rest
}
};
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"build:worker": "WEBPACK_ENTRY=\"./worker.js\" WEBPACK_OUTPUT_FILENAME=\"worker.min.js\" npx webpack --config webpack.config.js",
"build:worker-string": "node build-worker-string.js && node -r ./worker-string.js -e ''",
"build": "npm run build:worker && npm run build:worker-string && npm run build:main",
"format": "npx prettier --print-width=160 --trailing-comma=none --write build-worker-string.js constants.js index.cjs worker.js",
"format": "npx prettier --arrow-parens=avoid --print-width=160 --trailing-comma=none --write build-worker-string.js constants.js index.cjs worker.js",
"clean": "rm -fr worker.min.js worker-string.js index.min.js",
"prepublish": "npm run clean && npm run format && npm run build",
"serve": "npx srvd --debug --wait=infinity",
Expand All @@ -40,18 +40,18 @@
"dependencies": {
"frame-worker": "^0.1.0",
"geotiff": "^2.0.7",
"geotiff-tile": "^0.10.3",
"geotiff-tile": "^0.11.0",
"get-depth": "^0.0.3",
"quick-lru": "^6.1.1"
},
"devDependencies": {
"@babel/core": "^7.20.7",
"@babel/core": "^7.20.12",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.20.7",
"@babel/plugin-transform-runtime": "^7.19.6",
"@babel/preset-env": "^7.20.2",
"@babel/runtime": "^7.20.7",
"babel-loader": "^9.1.0",
"babel-loader": "^9.1.2",
"envisage": "^0.1.0",
"flug": "^2.3.1",
"srvd": "^0.6.0",
Expand Down
2 changes: 1 addition & 1 deletion worker-string.js

Large diffs are not rendered by default.

17 changes: 12 additions & 5 deletions worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,29 @@ const lru = new QuickLRU({ maxSize: 10 });

function pick(obj, keys) {
const result = {};
keys.forEach((key) => {
keys.forEach(key => {
result[key] = obj[key];
});
return result;
}

function getTransferList(data) {
const depth = getDepth(data);
if (depth === 1) return [data.buffer];
if (depth === 1) {
if (!data.buffer) return [];
return [data.buffer];
}

if (depth === 2) return data.map((band) => band.buffer);
if (depth === 2) {
if (!data[0].buffer) return [];
return data.map(band => band.buffer);
}

if (depth === 3) {
if (!data[0][0].buffer) return [];
const transferList = [];
data.forEach((arr1) => {
arr1.forEach((arr2) => {
data.forEach(arr1 => {
arr1.forEach(arr2 => {
transferList.push(arr2.buffer);
});
});
Expand Down

0 comments on commit f150b18

Please sign in to comment.