Coder Social home page Coder Social logo

node-walkdir's Introduction

node-walkdir

node traversal files (async/sync)

Linux Build Coverage Status Dependencies node license MIT

中文文档

Requirements

node8 or higher

How to use it

Installation

$ yarn add node-walkdir
# or
$ npm install node-walkdir

Examples

const walkdir = require('node-walkdir')

/** async */
(async() => {
  // walk all files by default
  const allFiles = await walk('you-path');
  console.log('files:', allFiles);

  // only traverse the JS files
  const jsFiles = await walk('you-path', '.js');
  console.log('files:', jsFiles);

  // traverse the JS and JSON files
  const jsonFiles = await walk('you-path', ['.js', '.json']);
  console.log('files:', jsonFiles);

  // traverse the JS and JSON files by regexp
  const json2Files = await walk('you-path', /\.js(on)?$/);
  console.log('files:', json2Files);

  // only traverse the JS files with 2 level directories deep.
  const js2Files = await walk('you-path', '.js', 2);
  console.log('files:', js2Files);
})();

/** sync */
// walk all files by default
const allFiles = walk.sync('you-path');
console.log('files:', allFiles);

// only traverse the JS files
const jsFiles = walk.sync('you-path', '.js');
console.log('files:', jsFiles);

// traverse the JS and JSON files
const jsonFiles = walk.sync('you-path', ['.js', '.json']);
console.log('files:', jsonFiles);

// traverse the JS and JSON files by regexp
const json2Files = walk.sync('you-path', /\.js(on)?$/);
console.log('files:', json2Files);

// only traverse the JS files with 2 level directories deep.
const js2Files = walk.sync('you-path', '.js', 2);
console.log('files:', js2Files);

node-walkdir's People

Contributors

52cik avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.