Socket
Socket
Sign inDemoInstall

sb-scandir

Package Overview
Dependencies
2
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sb-scandir

File scanning module for Node.js


Version published
Weekly downloads
98K
increased by6%
Maintainers
1
Install size
20.8 kB
Created
Weekly downloads
 

Changelog

Source

2.0.0

  • Change CJS export to ES Export
  • Return directories along with files

Readme

Source

ScanDir

Greenkeeper badge

sb-scandir is a node module that supports simple file scanning with some sugar features.

Installation

npm install --save sb-scandir

API

export default function scandir(path: string, recursive: boolean, validate: ((file: string) => boolean)): Promise<{ files: Array<string>, directories: Array<string> }>

Examples

import Path from 'path'
import scandir from 'sb-scandir'

// Scan all files except the dot ones
scandir(__dirname).then(function(result) {
  console.log('files', result.files)
  console.log('directories', result.directories)
})

// Scan all top level files except dot ones
scandir(__dirname, false).then(function(files) {
  console.log('files', result.files)
  console.log('directories', result.directories)
})

// Scan all files even the dot ones
scandir(__dirname, true, function(path) {
  return true
}).then(function(files) {
  console.log('files', result.files)
  console.log('directories', result.directories)
})

// Scan all files except in .git and node_modules
scandir(__dirname, true, function(path) {
  const baseName = Path.basename(path)
  return baseName !== '.git' && baseName !== 'node_modules'
}).then(function(files) {
  console.log('files', result.files)
  console.log('directories', result.directories)
})

License

This project is licensed under the terms of MIT License. See the LICENSE file for more info.

Keywords

FAQs

Last updated on 18 Sep 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc