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

enfscompare-promise

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enfscompare-promise

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

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

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Build Status AppVeyor status Codacy Badge Donate

NPM

enfscompare-promise

Module that add compare functionality to to node fs module with promises

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
    • filesP
    • filesHashP
    • dirP
    • dirHashP

Usage

enfscompare-promise

    const enfscompare = require("enfscompare-promise");

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)
    const 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)
    const result = enfscompare.filesHashSync("/home/name","/home/another_folder_name");
    if(result===true){
        console.log("Folders are equal");
    }

filesP

  • filesP(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.filesP("/home/name/file.txt", "/home/name/file.txt").then(function(result){
        if(result===true){
            console.log("File is equal");
        }
    });

dirP

  • dirP(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.dirP("/home/name", "/home/another_folder_name").then(function(result){
        if(result===true){
            console.log("Directories are equal");
        }
    });

filesHashP

  • filesHash(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)
    enfscompare.filesHashP("/home/name/file.txt","/home/name/file.txt").then(function(result){
        if(result===true){
            console.log("File is equal");
        }
    });

dirHashP

  • dirHash(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)
    enfscompare.dirHashP("/home/name","/home/another_folder_name").then(function(result){
        if(result===true){
            console.log("Folders are equal");
        }
    });

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 04 Apr 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