Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dir-compare

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dir-compare

Node JS directory compare

  • 4.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
256K
decreased by-56.44%
Maintainers
1
Weekly downloads
 
Created

What is dir-compare?

The dir-compare npm package is used to compare the contents of directories. It can compare files and subdirectories, providing detailed information about differences and similarities. This package is useful for tasks such as synchronizing directories, verifying backups, and ensuring consistency between different environments.

What are dir-compare's main functionalities?

Basic Directory Comparison

This feature allows you to compare two directories. The `compareSync` method performs a synchronous comparison, and the `compareContent` option ensures that file contents are compared as well.

const dircompare = require('dir-compare');
const options = { compareContent: true };
const res = dircompare.compareSync('path/to/dir1', 'path/to/dir2', options);
console.log(res);

Asynchronous Directory Comparison

This feature allows you to perform an asynchronous comparison of two directories. The `compare` method returns a promise that resolves with the comparison result.

const dircompare = require('dir-compare');
const options = { compareContent: true };
dircompare.compare('path/to/dir1', 'path/to/dir2', options)
  .then(res => console.log(res))
  .catch(error => console.error(error));

Custom Comparison Options

This feature allows you to customize the comparison process with various options. For example, you can exclude certain file types or include only specific file types in the comparison.

const dircompare = require('dir-compare');
const options = { compareContent: true, excludeFilter: '*.txt', includeFilter: '*.js' };
const res = dircompare.compareSync('path/to/dir1', 'path/to/dir2', options);
console.log(res);

Detailed Comparison Result

This feature provides detailed information about the comparison result. The `diffSet` property contains an array of differences, which you can iterate over to get detailed information about each difference.

const dircompare = require('dir-compare');
const options = { compareContent: true };
const res = dircompare.compareSync('path/to/dir1', 'path/to/dir2', options);
res.diffSet.forEach(dif => console.log(dif));

Other packages similar to dir-compare

Keywords

FAQs

Package last updated on 13 Aug 2023

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