MCPcopy Create free account
hub / github.com/denoland/std / eTag

Function eTag

http/etag.ts:151–166  ·  view source on GitHub ↗
(
  entity: string | ReturnType<TextEncoder["encode"]> | FileInfo,
  options: ETagOptions = {},
)

Source from the content-addressed store, hash-verified

149 options?: ETagOptions,
150): Promise<string | undefined>;
151export async function eTag(
152 entity: string | ReturnType<TextEncoder["encode"]> | FileInfo,
153 options: ETagOptions = {},
154): Promise<string | undefined> {
155 const weak = options.weak ?? isFileInfo(entity);
156 const tag =
157 await (isFileInfo(entity)
158 ? calcFileInfo(entity, options)
159 : calcEntity(entity, options));
160
161 if (!tag) {
162 return undefined;
163 }
164
165 return weak ? `W/"${tag}"` : `"${tag}"`;
166}
167
168const STAR_REGEXP = /^\s*\*\s*$/;
169const COMMA_REGEXP = /\s*,\s*/;

Callers 4

file_server.tsFile · 0.90
serveFileFunction · 0.90
fnFunction · 0.90

Calls 3

isFileInfoFunction · 0.85
calcFileInfoFunction · 0.85
calcEntityFunction · 0.85

Tested by

no test coverage detected