By default recent versions of mongodump create metadata files in the form of .metadata.json within the dump diretory. Theese files are not filtered and therefor restore breaks when tying to deserialize them as bson.
I suggest checking for !(/\.metadata\.json$/).test(docName) in fromJSON() before processing them further.