async function clearfolder( dir, threshold ) {
	/** @type {string[]} */
	let files = await fsReaddir( dir );

	// prepend dir path
	files = files.map( file => join( dir, file ) );

	let resolvedFiles;

	if ( !threshold ) {
		// just return all files if there is no threshold set
		const check = stat => isFile( stat );

		resolvedFiles = await execBatchAndIgnoreRejected( files, stat, check );

	} else {
		// ignore all files newer than X
		const now = Date.now();
		const check = stat => isFile( stat ) && now - stat.mtime > threshold;

		resolvedFiles = await execBatchAndIgnoreRejected( files, stat, check );
	}

	// delete all matched files
	return await execBatchAndIgnoreRejected( resolvedFiles, fsUnlink );
}
Delete files in a directory optionally filtered by age
@param {String} dir
@param {number?} threshold
@returns {Promise}