From 3ec761288f6b9d0e68e3f76d81ddc7e1166c07e7 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Thu, 18 Apr 2019 22:15:59 -0500 Subject: [PATCH] feat: add httparchive nostats subset --- bin/build-entity-json-files.js | 8 ++++++++ lib/subsets/httparchive-nostats.d.ts | 1 + lib/subsets/httparchive-nostats.js | 3 +++ package.json | 1 + 4 files changed, 13 insertions(+) create mode 100644 lib/subsets/httparchive-nostats.d.ts create mode 100644 lib/subsets/httparchive-nostats.js diff --git a/bin/build-entity-json-files.js b/bin/build-entity-json-files.js index c0d842e..7f41122 100644 --- a/bin/build-entity-json-files.js +++ b/bin/build-entity-json-files.js @@ -8,6 +8,10 @@ const DATA_DIR = path.join(__dirname, '../data') if (!fs.existsSync(DIST_DIR)) fs.mkdirSync(DIST_DIR) +function cleanStatsFromEntity(entity) { + return _.omit(entity, ['totalExecutionTime', 'totalOccurrences']) +} + const sourceEntities = JSON5.parse(fs.readFileSync(`${DATA_DIR}/entities.json5`, 'utf8')) fs.writeFileSync(`${DIST_DIR}/entities.json`, JSON.stringify(sourceEntities)) @@ -36,3 +40,7 @@ for (const entity of entitiesInHTTPArchive) { fs.writeFileSync(`${DIST_DIR}/entities.json`, JSON.stringify(sourceEntities)) fs.writeFileSync(`${DIST_DIR}/entities-httparchive.json`, JSON.stringify(entitiesInHTTPArchive)) +fs.writeFileSync( + `${DIST_DIR}/entities-httparchive-nostats.json`, + JSON.stringify(entitiesInHTTPArchive.map(e => cleanStatsFromEntity(e))), +) diff --git a/lib/subsets/httparchive-nostats.d.ts b/lib/subsets/httparchive-nostats.d.ts new file mode 100644 index 0000000..7389c0d --- /dev/null +++ b/lib/subsets/httparchive-nostats.d.ts @@ -0,0 +1 @@ +export * from '../index' diff --git a/lib/subsets/httparchive-nostats.js b/lib/subsets/httparchive-nostats.js new file mode 100644 index 0000000..0fa65c1 --- /dev/null +++ b/lib/subsets/httparchive-nostats.js @@ -0,0 +1,3 @@ +const {createAPIFromDataset} = require('../create-entity-finder-api.js') +const entities = require('../../dist/entities-httparchive-nostats.json') +module.exports = createAPIFromDataset(entities) diff --git a/package.json b/package.json index 7a79bf4..991889d 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ }, "config": { "exportAliases": { + "httparchive-nostats-subset": "./lib/subsets/httparchive-nostats.js", "httparchive-subset": "./lib/subsets/httparchive.js" } }