Skip to content

Commit f0d5549

Browse files
committed
Fixed post-install script
1 parent 98a62da commit f0d5549

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/post-install-2.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,21 @@ console.log('Creating index, this may take a minute...')
1919

2020

2121

22-
console.time('downloading')
22+
console.time('downloaded')
2323
await axios.get('https://raw.githubusercontent.com/ipapi-is/ipapi/main/databases/fullASN.json.zip', { responseType: 'arraybuffer' })
2424
.then((res) => writeFileSync(fileAsnsZip, res.data))
2525

2626
const zip = new AdmZip(fileAsnsZip)
2727
zip.extractAllTo(`${__dirname}/../data`, true)
28+
console.timeEnd('downloaded')
2829

29-
import data from '../data/fullASN.json' assert { type: 'json' }
30+
console.time('parsed')
31+
const data = JSON.parse(readFileSync('../data/fullASN.json').toString())
32+
console.timeEnd('parsed')
3033

3134
const keys = Object.keys(data)
32-
console.timeEnd('downloading')
3335

34-
35-
console.time('indexing')
36+
console.time('indexed')
3637

3738
function addToIndex(subnet, asn, ipFamily, country) {
3839
let ip
@@ -72,6 +73,6 @@ index.sort((a, b) => {
7273
}
7374
})
7475

75-
console.timeEnd('indexing')
76+
console.timeEnd('indexed')
7677

7778
writeFileSync(`${__dirname}/../data/asns_cidrs_2.csv`, index.map(({ asn, subnet, start, end, country }) => `${asn},${subnet},${start},${end},${country}`).join('\n'));

0 commit comments

Comments
 (0)