UNPKG

534 BJavaScriptView Raw
1const path = require('path')
2module.exports = (orderedFileList, count) => {
3 let candidateBn
4 let candidates = []
5 for (let i = 0; i < orderedFileList.length; i++) {
6 const bn = path.basename(orderedFileList[i], path.extname(orderedFileList[i]))
7 if (candidateBn === bn) {
8 candidates.push(orderedFileList[i])
9 } else {
10 candidates = []
11 candidateBn = bn
12 candidates.push(orderedFileList[i])
13 }
14 if (candidates.length === count) break
15 }
16 return candidates.length === count ? candidates : []
17}