New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@aminzer/dir-diff

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aminzer/dir-diff

Utility for recursive directory iteration and comparison

latest
Source
npmnpm
Version
5.1.6
Version published
Maintainers
1
Created
Source

Overview

NodeJS utility for recursive directory comparison.

Installation

npm i @aminzer/dir-diff

Usage examples

import { compareDirectories } from '@aminzer/dir-diff';

await compareDirectories('d:/work', 'e:/backups/work', {
  onSourceOnlyEntry: (fsEntry) => {
   console.log(`${fsEntry.isFile ? 'File' : 'Directory'} ${fsEntry.relativePath} exists in the source directory only`);
  },
  onTargetOnlyEntry: (fsEntry) => {
   console.log(`${fsEntry.isFile ? 'File' : 'Directory'} ${fsEntry.relativePath} exists in the target directory only`);
  },
  onDifferentEntries: (sourceFsEntry, targetFsEntry) => {
   console.log(`File ${sourceFsEntry.relativePath} exists in both source and target directories, but with different content`);
  },
});

API

compareDirectories

Overview

compareDirectories is used for recursive comparison of 2 directories.

compareDirectories(sourceDirPath, targetDirPath, opts)
Parameters
  • sourceDirPath (string, required) - path to the source directory.
  • targetDirPath (string, required) - path to the target directory.
  • opts (object, optional) - additional options to pass:
    • onSourceOnlyEntry (function, undefined by default) - function that is called for files and directories that are present in source directory, but are missing in target directory. Corresponding FsEntry instance is passed as parameter.
    • onTargetOnlyEntry (function, undefined by default) - function that is called for files and directories that are missing in source directory, but are present in target directory. Corresponding FsEntry instance is passed as parameter.
    • onDifferentEntries (function, undefined by default) - function that is called for files that are present in both source and target directories but have different content. Corresponding FsEntry instances are passed as parameters.
    • onEachEntry (function, undefined by default) - function that is called for all files and directories from both source and target directories. Corresponding FsEntry instance is passed as parameter.
    • skipContentComparison (boolean, false by default) - files are compared by size only. Content comparison is skipped. It speeds up execution by avoiding "expensive" content-comparison process for large files.
    • skipExcessNestedIterations (boolean, false by default) - children of source-only and target-only directories are not considered. It speeds up execution by avoiding recursive calls for such directories.
Return value

Promise that becomes fulfilled when directory comparison is completed.

FsEntry

Overview

FsEntry - class representing File System Entry (file or directory).

import { FsEntry } from '@aminzer/dir-diff';

Instance properties:

  • name (string) - name of entry.
  • absolutePath (string) - absolute path to entry.
  • relativePath (string) - relative path to entry. It's relative to source directory for source entries and relative to target directory for target entries.
  • size (number) - size of file in bytes, 0 for directories.
  • isFile (boolean) - true if entry is file.
  • isDirectory (boolean) - true if entry is directory.

Command line tool

@aminzer/dir-diff-cli

Keywords

directory

FAQs

Package last updated on 13 Mar 2026

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