Skip to content

Instantly share code, notes, and snippets.

Last active August 5, 2021 12:11
What would you like to do?
Get File Contents of Multiple Files as a Promise
import Promise from 'bluebird';
import {readFiles} from 'node-dir';
import {l} from './util';
* @param {String} root path
* @param {Object} options see:
* @return {Promise<String[]>}
export default function getFiles(root, options){
let contents = [];
return new Promise((resolve, reject) => {
readFiles(root, options,
function(err, content, next) {
if (err) throw err;
function(err, filenames){
if (err) return reject(err);
l('finished reading files');
Copy link

leap0x7b commented Aug 5, 2021

Why ES6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment