add copy of readdir.js for porting