New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-all-files

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-all-files

Few helpers to process all of the files in some folder

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

all-files

Build NPM

Helpers to process files recursively in folder with promises

Prereq

  • node 4
  • *nix, macOs

How to install

From NPM

npm install node-all-files or yarn add node-all-files

How to use

getFilenames

Getting all *.js files in folder ./test-dir:

const { getFilenames } = require('node-all-files');
const folder = __dirname + '/test-dir';

// Supports RegExp, String and Function for filtering:
getFilenames(folder, /\.js$/i);
//or
getFilenames(folder, '.js');
//or
getFilenames(folder, (f) => ~f.indexOf('.js'))
.then(({ files }) => {
  console.log(files);
});

processFiles

Showing content length of the files

const { processFiles } = require('node-all-files');
const files = [__filename];

processFiles(files, (buff, filename) => {
  // process file immediately
  console.log(buff.toString().length);

  // or return Promise
  return new Promise((resolve) => {
    setTimeout(resolve, 100);
  });
}).then(({results, errors}) => {
  // results - array of results
  // errors - object (map) with filename as key, and error (or reject reason) as value
  console.log('All files were processed');
});

How to test

  • npm test

Keywords

FAQs

Package last updated on 24 Feb 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc