UNPKG

qoe-pps

Version:

this is a qoe project of pps

41 lines (35 loc) 868 B
import usertiming from 'usertiming' export function byName (name) { return usertiming.getEntriesByName(name) } export function byType (type) { return usertiming.getEntriesByType(type || 'resource') } export function byFilter (filter, type) { let array = [] if (Object.prototype.toString.call(type) === '[object Array]') { array = type } else { array = byType(type) } return array.filter(filter) } export function byRegExp (reg, arg) { return byFilter(check(reg), arg) } function check (reg) { switch (Object.prototype.toString.call(reg)) { case '[object RegExp]': return function (item) { return reg.test(item.name) } case '[object String]': return function (item) { return item.name.indexOf(reg) !== -1 } default: return function (item) { return item.name } } }