Node.js v10.10.0 fs.readdirSync ponyfill of withFileTypes
option.
options.withFileTypes
is always set to true and result contain objects similar to fs.Dirent.
npm i fs-readdir-sync-with-file-types
path
<string> | <Buffer> | <URL>
Returns: <fs.Dirent[]>
Example:
const readdirSync = require('fs-readdir-sync-with-file-types');
readdirSync('.');
// returns on node v10.10
Dirent { name: 'LICENSE', [Symbol(type)]: 1 },
Dirent { name: 'README.md', [Symbol(type)]: 1 },
Dirent { name: 'index.js', [Symbol(type)]: 1 },
// returns on node < v10.10
{ name: 'LICENSE',
isBlockDevice: [Function: bound ],
isCharacterDevice: [Function: bound ],
isDirectory: [Function: bound ],
isFIFO: [Function: bound ],
isFile: [Function: bound ],
isSocket: [Function: bound ],
isSymbolicLink: [Function: bound ] },
{ name: 'README.md',
isBlockDevice: [Function: bound ],
isCharacterDevice: [Function: bound ],
isDirectory: [Function: bound ],
isFIFO: [Function: bound ],
isFile: [Function: bound ],
isSocket: [Function: bound ],
isSymbolicLink: [Function: bound ] },
{ name: 'index.js',
isBlockDevice: [Function: bound ],
isCharacterDevice: [Function: bound ],
isDirectory: [Function: bound ],
isFIFO: [Function: bound ],
isFile: [Function: bound ],
isSocket: [Function: bound ],
isSymbolicLink: [Function: bound ] }
- fs-copy-file - Asynchronously copies src to dest.
- fs-copy-file-sync - Synchronously copies src to dest.
- fs-readdir-with-file-types - Asynchronousely read directory with file types.
MIT