Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including scandir-async with all npm packages installed. Try it out:

var scandirAsync = require("scandir-async")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

scandir-async v0.1.15

Asynchronous directory/files iterator

scandir-async Built with Grunt

MIT License NPM version NPM downloads Build Coverage

  • Iterates trough a directory and returns a js object tree
  • Result can be directories/files sorted first


npm install scandir-async


var scandir = require('scandir-async'),
    exec = require('scandir-async').exec;
scandir.exec([folder], [options]).then(function(data){
    // Q.promise resolved
}, function(err){
    // Q.promise rejected
// or exposed
exec([folder], [options]).then(function(data){
    // Q.promise resolved
}, function(err){
    // Q.promise rejected

Tree Object

    isdir: true,
    name: dirname,
    fullpath: /abs/path/to/dirname,
    stats: {
        dev: 310691535,
         ino: 2814749767439347,
         uid: 0,
         gid: 0,
         rdev: 0,
         size: 0,
         mode: 16822,
         nlink: 1,
         blocks: false,
         blksize: false,
         atime: 1436683130000,
         mtime: 1436683130000,
         ctime: 1436683130000,
         birthtime: 1436683129000
    files: [{
            isdir: false,
            files: false,
            name: dirname,
            stats: [object],
            fullpath: /abs/path/to/dirname
        }, {
            isdir: true,
            files: [...],
            name: dirname,
            stats: [object],
            fullpath: /abs/path/to/dirname



  • absolute path

Options Object

Currently implemented

    sorted: false, // Default not sorted
    sorted: true, // 'ASC'
    sorted: 'ASC',
    sorted: 'DESC',

Not implemented yet

    depth: 0,
    filters: ['**/*.hml']



Git add/clone does not take care of empty folder used for tests, it must be created manually Or launch test using npm test

mkdir spec/expected/explore_method/subnofiles
mkdir spec/expected/files_method/nofile
mkdir spec/expected/files_method/threefile/subfolder


  • v0.1.15: Sorted fix name lowercase
  • v0.1.12: Sorted options added
  • v0.1.11: Files prop for directory is an array
  • v0.1.10: Changes on tree object
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free