Sha256: 87895e609ed7419f7ecdff800a76ca3ffb167f129dfd45f689875397f2348214

Contents?: true

Size: 593 Bytes

Versions: 26

Compression:

Stored size: 593 Bytes

Contents

const { join, resolve } = require('path');
const { readdir, stat } = require('fs');
const { promisify } = require('util');

const toStats = promisify(stat);
const toRead = promisify(readdir);

async function totalist(dir, callback, pre='') {
	dir = resolve('.', dir);
	await toRead(dir).then(arr => {
		return Promise.all(
			arr.map(str => {
				let abs = join(dir, str);
				return toStats(abs).then(stats => {
					return stats.isDirectory()
						? totalist(abs, callback, join(pre, str))
						: callback(join(pre, str), abs, stats)
				});
			})
		);
	});
}

exports.totalist = totalist;

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.6 lib/clapton/javascripts/node_modules/totalist/dist/index.js
clapton-0.0.5 lib/clapton/javascripts/node_modules/totalist/dist/index.js
clapton-0.0.4 lib/clapton/javascripts/node_modules/totalist/dist/index.js
clapton-0.0.3 lib/clapton/javascripts/node_modules/totalist/dist/index.js
clapton-0.0.2 lib/clapton/javascripts/node_modules/totalist/dist/index.js
clapton-0.0.1 lib/clapton/javascripts/node_modules/totalist/dist/index.js