aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@mrmlnc/readdir-enhanced/lib/stream/index.js
blob: 22a96094da3193addaa68e0c0aea24fc19b669b1 (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
'use strict';

module.exports = readdirStream;

const DirectoryReader = require('../directory-reader');

let streamFacade = {
  fs: require('fs'),
  forEach: require('../async/for-each'),
  async: true
};

/**
 * Returns the {@link stream.Readable} of an asynchronous {@link DirectoryReader}.
 *
 * @param {string} dir
 * @param {object} [options]
 * @param {object} internalOptions
 */
function readdirStream (dir, options, internalOptions) {
  internalOptions.facade = streamFacade;

  let reader = new DirectoryReader(dir, options, internalOptions);
  return reader.stream;
}