New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

h2-auto-push

Package Overview
Dependencies
Maintainers
7
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

h2-auto-push - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

3

build/src/asset-cache.d.ts
/// <reference types="node" />
import * as http2 from 'http2';
import http2 from 'http2';
export interface AssetCacheConfig {

@@ -14,2 +14,3 @@ warmupDuration: number;

private readonly assetMap;
private readonly pushCandidates;
constructor(config: AssetCacheConfig);

@@ -16,0 +17,0 @@ recordRequestPath(session: http2.Http2Session, path: string, isStatic: boolean): void;

@@ -26,2 +26,3 @@ "use strict";

this.assetMap = new Map();
this.pushCandidates = new Set();
}

@@ -48,3 +49,5 @@ recordRequestPath(session, path, isStatic) {

onWarm(path, session) {
if (this.assetMap.has(path))
// Don't use a path as a push key when it is also one of push candidates. It
// can cause a chain effect, causing unnecessary pushes.
if (this.assetMap.has(path) || this.pushCandidates.has(path))
return;

@@ -71,2 +74,5 @@ const sessionMapEntry = this.sessionMap.get(session);

this.assetMap.set(path, warmingMetricsEntry.paths);
for (const p of warmingMetricsEntry.paths) {
this.pushCandidates.add(p);
}
this.warmingMetrics.delete(path);

@@ -73,0 +79,0 @@ }

/// <reference types="node" />
import * as http2 from 'http2';
import http2 from 'http2';
import { AssetCacheConfig } from './asset-cache';

@@ -4,0 +4,0 @@ export { AssetCacheConfig } from './asset-cache';

@@ -15,7 +15,10 @@ "use strict";

// limitations under the License.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
}
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const path = require("path");
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const util_1 = require("util");
const fsStat = util_1.promisify(fs.stat);
const fsStat = util_1.promisify(fs_1.default.stat);
const asset_cache_1 = require("./asset-cache");

@@ -78,3 +81,3 @@ const client_cache_checker_1 = require("./client-cache-checker");

try {
const stats = await fsStat(path.join(this.rootDir, asset));
const stats = await fsStat(path_1.default.join(this.rootDir, asset));
if (pushedSize + stats.size > windowSize) {

@@ -97,6 +100,15 @@ continue;

const pushFile = (pushStream) => {
pushStream.on('finish', () => {
const onFinish = () => {
pushStream.removeListener('error', onError);
resolve();
});
pushStream.respondWithFile(path.join(this.rootDir, asset), undefined, {
};
const onError = (err) => {
console.error('push stream error for:', asset, err);
pushStream.removeListener('finish', onFinish);
pushStream.end();
reject(err);
};
pushStream.once('error', onError);
pushStream.once('finish', onFinish);
pushStream.respondWithFile(path_1.default.join(this.rootDir, asset), undefined, {
statCheck: (stats, headers) => {

@@ -103,0 +115,0 @@ this.addCacheHeaders(headers, stats);

{
"name": "h2-auto-push",
"version": "0.3.0",
"version": "0.3.1",
"description": "HTTP/2 auto-push library",

@@ -51,12 +51,12 @@ "main": "build/src/index.js",

"@types/get-port": "^3.2.0",
"@types/node": "^9.3.0",
"@types/semver": "^5.4.0",
"ava": "^0.24.0",
"@types/node": "^9.4.1",
"@types/semver": "^5.5.0",
"ava": "^0.25.0",
"codecov": "^3.0.0",
"get-port": "^3.2.0",
"gts": "^0.5.3",
"js-green-licenses": "^0.4.0",
"js-green-licenses": "^0.5.0",
"nyc": "^11.4.1",
"typescript": "~2.6.2"
"typescript": "~2.7.1"
}
}
# HTTP/2 automatic server push
[![Greenkeeper badge](https://badges.greenkeeper.io/google/node-h2-auto-push.svg)](https://greenkeeper.io/)
**This is not an official Google product.**

@@ -4,0 +6,0 @@

Sorry, the diff of this file is not supported yet

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