UNPKG

fs-iterator

Version:

A file system iterator with filter and asyncIterator iterafaces. Supports Node 0.10 and above

30 lines (29 loc) 759 B
import path from 'path'; function join(left, right) { if (!left) return right || ''; if (!right) return left; return left + path.sep + right; } export default function createEntry(iterator, item) { if (item.basename.name) { const stats = item.basename; const basename = stats.name.toString(); const path = join(item.path, basename); const fullPath = join(iterator.root, path); return { basename, stats, path, fullPath }; } const basename = item.basename; const path = join(item.path, basename); const fullPath = join(iterator.root, path); return { basename, stats: null, path, fullPath }; }