kopia lustrzana https://github.com/badgen/badgen.net
live-fns: add bundlephobia
rodzic
8858f22c3b
commit
f8c6c2571a
|
|
@ -165,6 +165,11 @@ Available icons:
|
|||
['publish size', '/packagephobia/publish/webpack'],
|
||||
['publish size (scoped)', '/packagephobia/publish/@tusbar/cache-control']
|
||||
],
|
||||
bundlephobia: [
|
||||
['minified', '/bundlephobia/min/react'],
|
||||
['minified + gzip', '/bundlephobia/minzip/react'],
|
||||
['(scoped) minified + gzip', '/bundlephobia/minzip/@nestjs/core']
|
||||
],
|
||||
'uptime robot': [
|
||||
['status', '/uptime-robot/status/m780731617-a9e038618dc1aee36a44c4af'],
|
||||
['(24 hours) uptime', '/uptime-robot/day/m780731617-a9e038618dc1aee36a44c4af'],
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
module.exports = {
|
||||
'amo': require('./amo.js'),
|
||||
'appveyor': require('./appveyor.js'),
|
||||
'bundlephobia': require('./bundlephobia.js'),
|
||||
'chrome-web-store': require('./chrome-web-store.js'),
|
||||
'circleci': require('./circleci.js'),
|
||||
'codecov': require('./codecov.js'),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
const axios = require('../axios.js')
|
||||
const byteSize = require('byte-size')
|
||||
|
||||
// https://github.com/pastelsky/bundlephobia/issues/4
|
||||
|
||||
module.exports = async function (topic, ...args) {
|
||||
const endpoint = `https://bundlephobia.com/api/size?package=${args.join('/')}`
|
||||
const { size, gzip } = await axios(endpoint).then(res => res.data)
|
||||
|
||||
switch (topic) {
|
||||
case 'min':
|
||||
return {
|
||||
subject: 'minified size',
|
||||
status: byteSize(size, { units: 'iec' }).toString(),
|
||||
color: 'blue'
|
||||
}
|
||||
case 'minzip':
|
||||
return {
|
||||
subject: 'minzipped size',
|
||||
status: byteSize(gzip, { units: 'iec' }).toString(),
|
||||
color: 'blue'
|
||||
}
|
||||
}
|
||||
}
|
||||
Ładowanie…
Reference in New Issue