Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tinyhttp/etag

Package Overview
Dependencies
Maintainers
2
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 0.2.1 to 0.2.2

6

CHANGELOG.md
# @tinyhttp/etag
## 0.2.2
### Patch Changes
- Return compression back
## 0.2.1

@@ -4,0 +10,0 @@

34

dist/index.js

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

import { createHash } from 'crypto';
import { Stats } from 'fs';
// Original module: https://github.com/jshttp/etag/blob/master/index.js
const entityTag = (entity) => {
if (entity.length === 0) {
// fast-path empty
return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
}
else {
// generate 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) + '"';
};
const etag = (entity, options) => {
if (entity == null) {
throw new TypeError('argument entity is required');
}
const weak = (options === null || options === void 0 ? void 0 : options.weak) || entity instanceof Stats;
// generate entity tag
const tag = entity instanceof Stats ? statTag(entity) : entityTag(entity);
return weak ? 'W/' + tag : tag;
};
export default etag;
import{createHash as r}from"crypto";import{Stats as t}from"fs";export default(e,n)=>{if(null==e)throw new TypeError("argument entity is required");const o=(null==n?void 0:n.t)||e instanceof t,f=e instanceof t?(({o:r,size:t})=>'"'+r.getTime().toString(16)+"-"+t.toString(16)+'"')(e):(t=>{if(0===t.length)return'"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';else{const e=r("sha1").update(t,"utf8").digest("base64").substring(0,27);return'"'+("string"==typeof t?Buffer.byteLength(t,"utf8"):t.length).toString(16)+"-"+e+'"'}})(e);return o?"W/"+f:f};
{
"name": "@tinyhttp/etag",
"version": "0.2.1",
"version": "0.2.2",
"type": "module",

@@ -5,0 +5,0 @@ "description": "entity tag module",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc