@fromdeno/cache
Advanced tools
Comparing version 0.1.6 to 0.1.7
{ | ||
"name": "@fromdeno/cache", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Simple API for Deno cache.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -40,3 +40,3 @@ // based on https://deno.land/x/cache@0.2.13 | ||
if (!home) return ".deno"; | ||
return Path.join(home, path); | ||
return Path.resolve(home, path); | ||
} |
@@ -8,4 +8,6 @@ import { Path, sha256 } from "./deps.deno.ts"; | ||
readonly hash: string; | ||
/** Path where the `Response` body is (or would be) cached. */ | ||
/** Path where the response body is (or would be) cached. */ | ||
readonly path: string; | ||
/** Path where the compiled JS is (or would be) cached. */ | ||
readonly jsPath: string; | ||
/** | ||
@@ -23,3 +25,3 @@ * Calculates where a gives URL is (or would be) cached. | ||
); | ||
this.path = Path.resolve( | ||
this.path = Path.join( | ||
getCacheDir(), | ||
@@ -31,5 +33,12 @@ "deps/", | ||
); | ||
this.jsPath = Path.join( | ||
getCacheDir(), | ||
"gen/", | ||
this.url.protocol.slice(0, -1), | ||
this.url.hostname, | ||
this.hash + ".js", | ||
); | ||
} | ||
/** Path where the `Response` `headers` are (or would be) cached. */ | ||
/** Path where the response headers are (or would be) cached. */ | ||
get metaPath(): string { | ||
@@ -45,7 +54,6 @@ return `${this.path}.metadata.json`; | ||
async read(options?: Deno.ReadFileOptions): Promise<Response> { | ||
const [body, meta] = await Promise.all([ | ||
const [body, { headers }] = await Promise.all([ | ||
Deno.readFile(this.path, options), | ||
Deno.readTextFile(this.metaPath, options).then(JSON.parse), | ||
]); | ||
const headers = new Headers(meta.headers); | ||
return new Response(body, { headers }); | ||
@@ -52,0 +60,0 @@ } |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
0
9231
12
204