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

enfscompare

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enfscompare

Add folder and file comparison method's to node fs module

  • 1.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Build Status Build status Codacy Badge Donate

NPM

enfscompare

Module that add compare functionality to to node fs module

This module is intended to work as a sub-module of enfs

Description

This module will add a method that allows the comparison of files and folders.

  • This module will add following methods to node fs module:
    • files
    • filesHash
    • filesSync
    • filesHashSync
    • dir
    • dirHash
    • dirSync
    • dirHashSync

Usage

enfscompare

    var enfscompare = require("enfscompare");

Errors

All the methods follows the node culture.

  • Async: Every async method returns an Error in the first callback parameter
  • Sync: Every sync method throws an Error.

Additional Methods

files

filesSync

  • files(path1, path2, [options], callback)
  • filesSync(path1, path2, [options])

Compare files in a byte-to-byte form

[options]:

  • fs (Object): an alternative fs module to use (default will be enfspatch)
  • dereference (Boolean): if true will dereference symlinks listing the items to where it points (default: false)
  • chunkSize (Number) - the size in bytes used to read files and verify equality default to (async: ReadStream._readableState.highWaterMark, sync: 8192)
    enfscompare.files("/home/name/file.txt", "/home/name/file.txt", function(err, result){
        if(result===true){
            console.log("File is equal");
        }
    });

dir

dirSync

  • dir(path1, path2, [options], callback)
  • dirSync(path1, path2, [options])

Compare files in a byte-to-byte form

[options]:

  • fs (Object): an alternative fs module to use (default will be enfspatch)
  • dereference (Boolean): if true will dereference symlinks listing the items to where it points (default: false)
  • chunkSize (Number) - the size in bytes used to read files and verify equality default to (async: ReadStream._readableState.highWaterMark, sync: 8192)
    enfscompare.dir("/home/name", "/home/another_folder_name", function(err, result){
        if(result===true){
            console.log("Directories are equal");
        }
    });

filesHash

filesHashSync

  • filesHash(path1, path2, [options], callback)
  • filesHashSync(path1, path2, [options])

Compare files with an hash NOTE: This method can't correctly tell you that the files are equal, but can tell you if they are different

[options]:

  • fs (Object): an alternative fs module to use (default will be enfspatch)
  • dereference (Boolean): if true will dereference symlinks listing the items to where it points (default: false)
  • hash (String) - the type of hash to use in comparison, default to 'sha512'
  • encoding (String) - the type of hash encoding used to compare the files, default to 'hex'
  • chunkSize (String) - the size in bytes used to read files default 8192 (Only in sync method)
    var result = enfscompare.filesHashSync("/home/name/file.txt","/home/name/file.txt");
    if(result===true){
        console.log("File is equal");
    }

dirHash

dirHashSync

  • dirHash(path1, path2, [options], callback)
  • dirHashSync(path1, path2, [options])

Compare files with an hash NOTE: This method can't correctly tell you that the files are equal, but can tell you if they are different

[options]:

  • fs (Object): an alternative fs module to use (default will be enfspatch)
  • dereference (Boolean): if true will dereference symlinks listing the items to where it points (default: false)
  • hash (String) - the type of hash to use in comparison, default to 'sha512'
  • encoding (String) - the type of hash encoding used to compare the files, default to 'hex'
  • chunkSize (String) - the size in bytes used to read files default 8192 (Only in sync method)
    var result = enfscompare.filesHashSync("/home/name","/home/another_folder_name");
    if(result===true){
        console.log("Folders are equal");
    }

Benchmarks

Run the files in benchmarks folder to check which algorithm is fastest in your machine with different file sizes

License

Creative Commons Attribution 4.0 International License

Copyright (c) 2016 Joao Parreira joaofrparreira@gmail.com GitHub

This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit CC-BY-4.0.

Keywords

FAQs

Package last updated on 31 Mar 2017

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