browsertime
Version:
Get performance metrics from your web page using Browsertime.
20 lines (18 loc) • 586 B
JavaScript
import { promisify } from 'node:util';
import { stat as _stat } from 'node:fs';
import path from 'node:path';
const stat = promisify(_stat);
/**
* Filters to use with Array.prototype.filter, e.g. ['/a/path', '/another/path'].filter(onlyFiles)
*/
export function onlyWithExtension(extension) {
return filepath => path.extname(filepath) === extension;
}
export async function onlyFiles(filepath) {
const stats = await stat(filepath);
return stats.isFile();
}
export async function onlyDirectories(filepath) {
const stats = await stat(filepath);
return stats.isDirectory();
}