re-prettier pmtiles.ts; add prettier task

This commit is contained in:
Brandon Liu
2022-02-17 14:18:27 +08:00
parent c4560be9a2
commit 802b5e46fd
2 changed files with 364 additions and 379 deletions

View File

@@ -15,7 +15,8 @@
"build-tsc": "tsc --declaration --outdir dist",
"build": "npm run build-iife && npm run build-esm && npm run build-tsc",
"test": "node -r esbuild-runner/register pmtiles.test.ts",
"tsc": "tsc --noEmit --watch"
"tsc": "tsc --noEmit --watch",
"prettier": "prettier --write pmtiles.ts"
},
"homepage": "https://github.com/protomaps/pmtiles",
"author": "Brandon Liu",

View File

@@ -82,10 +82,7 @@ const queryView = (
} else if (cmp < 0) {
n = k - 1;
} else {
return [
getUint48(view, k * 17 + 7),
view.getUint32(k * 17 + 13, true),
];
return [getUint48(view, k * 17 + 7), view.getUint32(k * 17 + 13, true)];
}
}
return null;
@@ -293,10 +290,7 @@ export class PMTiles {
let resp = await fetch(this.url, {
headers: {
Range:
"bytes=" +
entry.offset +
"-" +
(entry.offset + entry.length - 1),
"bytes=" + entry.offset + "-" + (entry.offset + entry.length - 1),
},
});
var buf = await resp.arrayBuffer();
@@ -309,10 +303,7 @@ export class PMTiles {
return buf;
};
getLeafdir = async (
version: number,
entry: Entry
): Promise<ArrayBuffer> => {
getLeafdir = async (version: number, entry: Entry): Promise<ArrayBuffer> => {
let leaf = this.leaves.get(entry.offset);
if (leaf) return await leaf.buffer;
@@ -350,10 +341,7 @@ export class PMTiles {
);
if (leafdir_entry) {
let leafdir = await this.getLeafdir(
root.header.version,
leafdir_entry
);
let leafdir = await this.getLeafdir(root.header.version, leafdir_entry);
return queryTile(new DataView(leafdir), z, x, y);
}
return null;
@@ -441,11 +429,7 @@ export const addProtocol = (maplibregl: any) => {
instance.getZxy(+z, +x, +y).then((val) => {
if (val) {
let headers = {
Range:
"bytes=" +
val.offset +
"-" +
(val.offset + val.length - 1),
Range: "bytes=" + val.offset + "-" + (val.offset + val.length - 1),
};
const controller = new AbortController();
const signal = controller.signal;