aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@mrmlnc/readdir-enhanced/lib/index.js
blob: f77d2c6a18e958e4ce696602905010974250f791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
'use strict';

const readdirSync = require('./sync');
const readdirAsync = require('./async');
const readdirStream = require('./stream');

module.exports = exports = readdirAsyncPath;
exports.readdir = exports.readdirAsync = exports.async = readdirAsyncPath;
exports.readdirAsyncStat = exports.async.stat = readdirAsyncStat;
exports.readdirStream = exports.stream = readdirStreamPath;
exports.readdirStreamStat = exports.stream.stat = readdirStreamStat;
exports.readdirSync = exports.sync = readdirSyncPath;
exports.readdirSyncStat = exports.sync.stat = readdirSyncStat;

/**
 * Synchronous readdir that returns an array of string paths.
 *
 * @param {string} dir
 * @param {object} [options]
 * @returns {string[]}
 */
function readdirSyncPath (dir, options) {
  return readdirSync(dir, options, {});
}

/**
 * Synchronous readdir that returns results as an array of {@link fs.Stats} objects
 *
 * @param {string} dir
 * @param {object} [options]
 * @returns {fs.Stats[]}
 */
function readdirSyncStat (dir, options) {
  return readdirSync(dir, options, { stats: true });
}

/**
 * Aynchronous readdir (accepts an error-first callback or returns a {@link Promise}).
 * Results are an array of path strings.
 *
 * @param {string} dir
 * @param {object} [options]
 * @param {function} [callback]
 * @returns {Promise<string[]>}
 */
function readdirAsyncPath (dir, options, callback) {
  return readdirAsync(dir, options, callback, {});
}

/**
 * Aynchronous readdir (accepts an error-first callback or returns a {@link Promise}).
 * Results are an array of {@link fs.Stats} objects.
 *
 * @param {string} dir
 * @param {object} [options]
 * @param {function} [callback]
 * @returns {Promise<fs.Stats[]>}
 */
function readdirAsyncStat (dir, options, callback) {
  return readdirAsync(dir, options, callback, { stats: true });
}

/**
 * Aynchronous readdir that returns a {@link stream.Readable} (which is also an {@link EventEmitter}).
 * All stream data events ("data", "file", "directory", "symlink") are passed a path string.
 *
 * @param {string} dir
 * @param {object} [options]
 * @returns {stream.Readable}
 */
function readdirStreamPath (dir, options) {
  return readdirStream(dir, options, {});
}

/**
 * Aynchronous readdir that returns a {@link stream.Readable} (which is also an {@link EventEmitter})
 * All stream data events ("data", "file", "directory", "symlink") are passed an {@link fs.Stats} object.
 *
 * @param {string} dir
 * @param {object} [options]
 * @returns {stream.Readable}
 */
function readdirStreamStat (dir, options) {
  return readdirStream(dir, options, { stats: true });
}