Skip to content

Commit f6c6159

Browse files
committed
fix: use entity data for dist/
1 parent b09f4d2 commit f6c6159

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

bin/build-entity-json-files.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function cleanStatsFromEntity(entity) {
1515
const sourceEntities = JSON5.parse(fs.readFileSync(`${DATA_DIR}/entities.json5`, 'utf8'))
1616
fs.writeFileSync(`${DIST_DIR}/entities.json`, JSON.stringify(sourceEntities))
1717

18-
const httpArchiveData = require('../data/2019-03-01-origin-scripting.json')
18+
const httpArchiveData = require('../data/2019-04-01-entity-scripting.json')
1919
const {getEntity} = require('../lib/index.js') // IMPORTANT: require this after entities have been written
2020
const entityExecutionStats = _(httpArchiveData)
2121
.groupBy(({origin}) => {
@@ -47,5 +47,5 @@ fs.writeFileSync(`${DIST_DIR}/entities.json`, JSON.stringify(sourceEntities))
4747
fs.writeFileSync(`${DIST_DIR}/entities-httparchive.json`, JSON.stringify(entitiesInHTTPArchive))
4848
fs.writeFileSync(
4949
`${DIST_DIR}/entities-httparchive-nostats.json`,
50-
JSON.stringify(entitiesInHTTPArchive.map(e => cleanStatsFromEntity(e))),
50+
JSON.stringify(entitiesInHTTPArchive.map(e => cleanStatsFromEntity(e)))
5151
)

lib/index.test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('getEntity', () => {
2525
it('works for direct domain usage', () => {
2626
expect(getEntity('https://js.connect.facebook.net/lib.js')).toMatchInlineSnapshot(`
2727
Object {
28-
"averageExecutionTime": 119.80635511714381,
28+
"averageExecutionTime": 142.3708560765058,
2929
"categories": Array [
3030
"social",
3131
],
@@ -54,16 +54,16 @@ Object {
5454
],
5555
"homepage": "https://www.facebook.com",
5656
"name": "Facebook",
57-
"totalExecutionTime": 132167256,
58-
"totalOccurrences": 1103174,
57+
"totalExecutionTime": 144421993,
58+
"totalOccurrences": 1014407,
5959
}
6060
`)
6161
})
6262

6363
it('works for inferred domain usage', () => {
6464
expect(getEntity('https://unknown.typekit.net/fonts.css')).toMatchInlineSnapshot(`
6565
Object {
66-
"averageExecutionTime": 95.1277705345502,
66+
"averageExecutionTime": 91.7116918051686,
6767
"categories": Array [
6868
"library",
6969
],
@@ -75,8 +75,8 @@ Object {
7575
],
7676
"homepage": "https://fonts.adobe.com/",
7777
"name": "Adobe TypeKit",
78-
"totalExecutionTime": 656667,
79-
"totalOccurrences": 6903,
78+
"totalExecutionTime": 954627,
79+
"totalOccurrences": 10409,
8080
}
8181
`)
8282
})

0 commit comments

Comments
 (0)