mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 10:51:07 +00:00
* Work through linter issues related to non-null checks and any.
This commit is contained in:
@@ -77,7 +77,7 @@ export const leafletRasterLayer = (source: PMTiles, options: any) => {
|
||||
// copied from MapLibre /util/ajax.ts
|
||||
type RequestParameters = {
|
||||
url: string;
|
||||
headers?: any;
|
||||
headers?: unknown;
|
||||
method?: "GET" | "POST" | "PUT";
|
||||
body?: string;
|
||||
type?: "string" | "json" | "arrayBuffer" | "image";
|
||||
@@ -87,7 +87,7 @@ type RequestParameters = {
|
||||
|
||||
type ResponseCallback = (
|
||||
error?: Error | null,
|
||||
data?: any | null,
|
||||
data?: unknown | null,
|
||||
cacheControl?: string | null,
|
||||
expires?: string | null
|
||||
) => void;
|
||||
|
||||
52
js/index.ts
52
js/index.ts
@@ -296,10 +296,13 @@ export class FetchSource implements Source {
|
||||
async getBytes(
|
||||
offset: number,
|
||||
length: number,
|
||||
signal?: AbortSignal
|
||||
passedSignal?: AbortSignal
|
||||
): Promise<RangeResponse> {
|
||||
let controller;
|
||||
if (!signal) {
|
||||
let controller: AbortController | undefined;
|
||||
let signal: AbortSignal | undefined;
|
||||
if (passedSignal) {
|
||||
signal = passedSignal;
|
||||
} else {
|
||||
// TODO check this works or assert 206
|
||||
controller = new AbortController();
|
||||
signal = controller.signal;
|
||||
@@ -567,9 +570,10 @@ export class ResolvedValueCache {
|
||||
|
||||
async getHeader(source: Source, currentEtag?: string): Promise<Header> {
|
||||
const cacheKey = source.getKey();
|
||||
if (this.cache.has(cacheKey)) {
|
||||
this.cache.get(cacheKey)!.lastUsed = this.counter++;
|
||||
const data = this.cache.get(cacheKey)?.data;
|
||||
const cacheValue = this.cache.get(cacheKey);
|
||||
if (cacheValue) {
|
||||
cacheValue.lastUsed = this.counter++;
|
||||
const data = cacheValue.data;
|
||||
return data as Header;
|
||||
}
|
||||
|
||||
@@ -603,9 +607,10 @@ export class ResolvedValueCache {
|
||||
const cacheKey = `${source.getKey()}|${
|
||||
header.etag || ""
|
||||
}|${offset}|${length}`;
|
||||
if (this.cache.has(cacheKey)) {
|
||||
this.cache.get(cacheKey)!.lastUsed = this.counter++;
|
||||
const data = this.cache.get(cacheKey)?.data;
|
||||
const cacheValue = this.cache.get(cacheKey);
|
||||
if (cacheValue) {
|
||||
cacheValue.lastUsed = this.counter++;
|
||||
const data = cacheValue.data;
|
||||
return data as Entry[];
|
||||
}
|
||||
|
||||
@@ -634,9 +639,10 @@ export class ResolvedValueCache {
|
||||
const cacheKey = `${source.getKey()}|${
|
||||
header.etag || ""
|
||||
}|${offset}|${length}`;
|
||||
if (this.cache.has(cacheKey)) {
|
||||
this.cache.get(cacheKey)!.lastUsed = this.counter++;
|
||||
const data = await this.cache.get(cacheKey)?.data;
|
||||
const cacheValue = this.cache.get(cacheKey);
|
||||
if (cacheValue) {
|
||||
cacheValue.lastUsed = this.counter++;
|
||||
const data = await cacheValue.data;
|
||||
return data as ArrayBuffer;
|
||||
}
|
||||
|
||||
@@ -704,9 +710,10 @@ export class SharedPromiseCache {
|
||||
|
||||
async getHeader(source: Source, currentEtag?: string): Promise<Header> {
|
||||
const cacheKey = source.getKey();
|
||||
if (this.cache.has(cacheKey)) {
|
||||
this.cache.get(cacheKey)!.lastUsed = this.counter++;
|
||||
const data = await this.cache.get(cacheKey)?.data;
|
||||
const cacheValue = this.cache.get(cacheKey);
|
||||
if (cacheValue) {
|
||||
cacheValue.lastUsed = this.counter++;
|
||||
const data = await cacheValue.data;
|
||||
return data as Header;
|
||||
}
|
||||
|
||||
@@ -739,9 +746,10 @@ export class SharedPromiseCache {
|
||||
const cacheKey = `${source.getKey()}|${
|
||||
header.etag || ""
|
||||
}|${offset}|${length}`;
|
||||
if (this.cache.has(cacheKey)) {
|
||||
this.cache.get(cacheKey)!.lastUsed = this.counter++;
|
||||
const data = await this.cache.get(cacheKey)?.data;
|
||||
const cacheValue = this.cache.get(cacheKey);
|
||||
if (cacheValue) {
|
||||
cacheValue.lastUsed = this.counter++;
|
||||
const data = await cacheValue.data;
|
||||
return data as Entry[];
|
||||
}
|
||||
|
||||
@@ -769,9 +777,10 @@ export class SharedPromiseCache {
|
||||
const cacheKey = `${source.getKey()}|${
|
||||
header.etag || ""
|
||||
}|${offset}|${length}`;
|
||||
if (this.cache.has(cacheKey)) {
|
||||
this.cache.get(cacheKey)!.lastUsed = this.counter++;
|
||||
const data = await this.cache.get(cacheKey)?.data;
|
||||
const cacheValue = this.cache.get(cacheKey);
|
||||
if (cacheValue) {
|
||||
cacheValue.lastUsed = this.counter++;
|
||||
const data = await cacheValue.data;
|
||||
return data as ArrayBuffer;
|
||||
}
|
||||
|
||||
@@ -817,6 +826,7 @@ export class SharedPromiseCache {
|
||||
}
|
||||
}
|
||||
|
||||
// biome-ignore lint: that's just how its capitalized
|
||||
export class PMTiles {
|
||||
source: Source;
|
||||
cache: Cache;
|
||||
|
||||
Reference in New Issue
Block a user