printer-notifications/node_modules/totalist/sync/index.mjs
2023-11-13 16:10:04 -05:00

16 lines
414 B
JavaScript

import { join, resolve } from 'path';
import { readdirSync, statSync } from 'fs';
export function totalist(dir, callback, pre='') {
dir = resolve('.', dir);
let arr = readdirSync(dir);
let i=0, abs, stats;
for (; i < arr.length; i++) {
abs = join(dir, arr[i]);
stats = statSync(abs);
stats.isDirectory()
? totalist(abs, callback, join(pre, arr[i]))
: callback(join(pre, arr[i]), abs, stats);
}
}