🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

@tinyhttp/etag

Package Overview
Dependencies
Maintainers
0
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinyhttp/etag - npm Package Compare versions

Comparing version
2.1.1
to
2.1.2
+4
vite.config.ts
import { build } from '../../config/build'
import { dependencies } from './package.json'
export default build(dependencies)
+1
-2

@@ -1,4 +0,3 @@

/// <reference types="node" />
/// <reference types="node" />
import { Stats } from 'node:fs';
export declare const eTag: (entity: string | Buffer | Stats, options?: {

@@ -5,0 +4,0 @@ weak: boolean;

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAuB/B,eAAO,MAAM,IAAI,WAAY,MAAM,GAAG,MAAM,GAAG,KAAK,YAAY;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,KAAG,MAUnF,CAAA"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAsB/B,eAAO,MAAM,IAAI,WAAY,MAAM,GAAG,MAAM,GAAG,KAAK,YAAY;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,KAAG,MAUnF,CAAA"}

@@ -6,17 +6,15 @@ import { createHash } from "node:crypto";

return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
} else {
const hash = createHash("sha1").update(entity, "utf8").digest("base64").substring(0, 27);
const len = typeof entity === "string" ? Buffer.byteLength(entity, "utf8") : entity.length;
return '"' + len.toString(16) + "-" + hash + '"';
}
const hash = createHash("sha1").update(entity, "utf8").digest("base64").substring(0, 27);
const len = typeof entity === "string" ? Buffer.byteLength(entity, "utf8") : entity.length;
return `"${len.toString(16)}-${hash}"`;
};
const statTag = ({ mtime, size }) => {
return '"' + mtime.getTime().toString(16) + "-" + size.toString(16) + '"';
return `"${mtime.getTime().toString(16)}-${size.toString(16)}"`;
};
const eTag = (entity, options) => {
if (entity == null)
throw new TypeError("argument entity is required");
if (entity == null) throw new TypeError("argument entity is required");
const weak = (options == null ? void 0 : options.weak) || entity instanceof Stats;
const tag = entity instanceof Stats ? statTag(entity) : entityTag(entity);
return weak ? "W/" + tag : tag;
return weak ? `W/${tag}` : tag;
};

@@ -23,0 +21,0 @@ export {

@@ -1,1 +0,1 @@

{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["// Original module: https://github.com/jshttp/etag/blob/master/index.js\n\nimport { createHash } from 'node:crypto'\nimport { Stats } from 'node:fs'\n\nconst entityTag = (entity: string | Buffer): string => {\n if (entity.length === 0) {\n // fast-path empty\n return '\"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk\"'\n } else {\n // generate hash\n const hash = createHash('sha1')\n .update(entity as string, 'utf8')\n .digest('base64')\n .substring(0, 27)\n\n const len = typeof entity === 'string' ? Buffer.byteLength(entity, 'utf8') : entity.length\n\n return '\"' + len.toString(16) + '-' + hash + '\"'\n }\n}\n\nconst statTag = ({ mtime, size }: Stats): string => {\n return '\"' + mtime.getTime().toString(16) + '-' + size.toString(16) + '\"'\n}\n\nexport const eTag = (entity: string | Buffer | Stats, options?: { weak: boolean }): string => {\n if (entity == null) throw new TypeError('argument entity is required')\n\n const weak = options?.weak || entity instanceof Stats\n\n // generate entity tag\n\n const tag = entity instanceof Stats ? statTag(entity) : entityTag(entity)\n\n return weak ? 'W/' + tag : tag\n}\n"],"names":[],"mappings":";;AAKA,MAAM,YAAY,CAAC,WAAoC;AACjD,MAAA,OAAO,WAAW,GAAG;AAEhB,WAAA;AAAA,EAAA,OACF;AAEL,UAAM,OAAO,WAAW,MAAM,EAC3B,OAAO,QAAkB,MAAM,EAC/B,OAAO,QAAQ,EACf,UAAU,GAAG,EAAE;AAEZ,UAAA,MAAM,OAAO,WAAW,WAAW,OAAO,WAAW,QAAQ,MAAM,IAAI,OAAO;AAEpF,WAAO,MAAM,IAAI,SAAS,EAAE,IAAI,MAAM,OAAO;AAAA,EAC/C;AACF;AAEA,MAAM,UAAU,CAAC,EAAE,OAAO,WAA0B;AAC3C,SAAA,MAAM,MAAM,QAAA,EAAU,SAAS,EAAE,IAAI,MAAM,KAAK,SAAS,EAAE,IAAI;AACxE;AAEa,MAAA,OAAO,CAAC,QAAiC,YAAwC;AAC5F,MAAI,UAAU;AAAY,UAAA,IAAI,UAAU,6BAA6B;AAE/D,QAAA,QAAO,mCAAS,SAAQ,kBAAkB;AAIhD,QAAM,MAAM,kBAAkB,QAAQ,QAAQ,MAAM,IAAI,UAAU,MAAM;AAEjE,SAAA,OAAO,OAAO,MAAM;AAC7B;"}
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["// Original module: https://github.com/jshttp/etag/blob/master/index.js\n\nimport { createHash } from 'node:crypto'\nimport { Stats } from 'node:fs'\n\nconst entityTag = (entity: string | Buffer): string => {\n if (entity.length === 0) {\n // fast-path empty\n return '\"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk\"'\n }\n // generate hash\n const hash = createHash('sha1')\n .update(entity as string, 'utf8')\n .digest('base64')\n .substring(0, 27)\n\n const len = typeof entity === 'string' ? Buffer.byteLength(entity, 'utf8') : entity.length\n\n return `\"${len.toString(16)}-${hash}\"`\n}\n\nconst statTag = ({ mtime, size }: Stats): string => {\n return `\"${mtime.getTime().toString(16)}-${size.toString(16)}\"`\n}\n\nexport const eTag = (entity: string | Buffer | Stats, options?: { weak: boolean }): string => {\n if (entity == null) throw new TypeError('argument entity is required')\n\n const weak = options?.weak || entity instanceof Stats\n\n // generate entity tag\n\n const tag = entity instanceof Stats ? statTag(entity) : entityTag(entity)\n\n return weak ? `W/${tag}` : tag\n}\n"],"names":[],"mappings":";;AAKA,MAAM,YAAY,CAAC,WAAoC;AACjD,MAAA,OAAO,WAAW,GAAG;AAEhB,WAAA;AAAA,EACT;AAEA,QAAM,OAAO,WAAW,MAAM,EAC3B,OAAO,QAAkB,MAAM,EAC/B,OAAO,QAAQ,EACf,UAAU,GAAG,EAAE;AAEZ,QAAA,MAAM,OAAO,WAAW,WAAW,OAAO,WAAW,QAAQ,MAAM,IAAI,OAAO;AAEpF,SAAO,IAAI,IAAI,SAAS,EAAE,CAAC,IAAI,IAAI;AACrC;AAEA,MAAM,UAAU,CAAC,EAAE,OAAO,WAA0B;AAC3C,SAAA,IAAI,MAAM,QAAA,EAAU,SAAS,EAAE,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;AAC9D;AAEa,MAAA,OAAO,CAAC,QAAiC,YAAwC;AAC5F,MAAI,UAAU,KAAY,OAAA,IAAI,UAAU,6BAA6B;AAE/D,QAAA,QAAO,mCAAS,SAAQ,kBAAkB;AAIhD,QAAM,MAAM,kBAAkB,QAAQ,QAAQ,MAAM,IAAI,UAAU,MAAM;AAEjE,SAAA,OAAO,KAAK,GAAG,KAAK;AAC7B;"}
{
"name": "@tinyhttp/etag",
"version": "2.1.1",
"version": "2.1.2",
"type": "module",

@@ -30,5 +30,3 @@ "description": "entity tag module",

"license": "MIT",
"files": [
"dist"
],
"dependencies": {},
"scripts": {

@@ -35,0 +33,0 @@ "dev": "vite",