Skip to main content
function encode
import { encode } from "https://deno.land/x/etag@0.0.1/mod.ts";

Calculate an ETag value for an entity. If the entity is FileInfo, then the tag will default to a weak ETag. options.weak overrides any default behavior in generating the tag.

Examples

Example 1

import * as etag from "https://deno.land/x/etag@0.0.1/mod.ts";
import $ from "https://deno.land/x/dax/mod.ts";

for await (const f of $.fs.expandGlob("./src/*.ts")) {
  console.log(f.name);
  const stat = Deno.statSync(f.path);
  const tag = etag.encode(stat);
  console.log("  stat:\n\t%s", JSON.stringify(stat, null, 2));
  console.log("  eTag:\n\t%s", tag);
}

Parameters

entity: Entity

A string, Uint8Array, or file info to use to generate the ETag

optional
options: Options = [UNSUPPORTED]

either a boolean - a shorthand way to set options.weak - or an object of type { weak?: boolean; statTag?: boolean; }

Returns

string