npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

folderbsdp

v1.0.2

Published

FolderBsdp algorithm utilizes bsdp algorithm and file operations to provides diffing and patching capacities for two folders

Downloads

3

Readme

What is FolderBsdp?

FolderBsdp is an algorithm which utilizes bsdp algorithm and file operations to provide diffing and patching capacities for two folders. Bsdp is a famous algorithm which is open source, known as bsdiff. The name bsdp is the npm module name, as well as the combination between bsdiff and bspatch. Bsdp can diff two files but does not support diffing between folders. The name FolderBsdp contains the prefix Folder, which means that it diffs two folders. It keeps the API almost the same (input params are the same while returns promise instead).

What does FolderBsdp do?

FolderBsdp compares two folders and provide the patch file (which is a zip actually). In the patch, it contains the resources to help modifying folder A's content to become folder B's content, including adding/removing directories and files, changing file content. In another word, the patch file stores the difference between two folders. FolderBsdp uses file operation and bsdp algorithm. The motivation to come up with such an algorithm is that bsdp cannot diff two folders while diffing zip compress files is not optimal for reducing patch file size (compression algorithm enlarges the difference. If you are able to read Chinese, refer to https://mp.weixin.qq.com/s/qAuVQCMs7SJij3Nk0gw_bA (#^.^#)).

How to use FolderBsdp?

This package supports ESM and CommonJS. We use ESM here as the example.

Install

npm install folderbsdp --save

Use API

import FolderBsdp from "FolderBsdp"
FolderBsdp.diff("./Users/myname/Documents/Afolder", "./Users/myname/Documents/Bfolder", "./Users/myname/Documents/ABdifference.patch")
FolderBsdp.patch("./Users/myname/Documents/Afolder", "./Users/myname/Documents/Bfolder", "./Users/myname/Documents/ABdifference.patch")

Explanation of API

FolderBsdp.diff("./Users/myname/Documents/Afolder", "./Users/myname/Documents/Bfolder", "./Users/myname/Documents/ABdifference.patch")

In the code above, it lists A folder's directory and B folder's directory as the resources, the patch result will be written to path "./Users/myname/Documents/" with file name "ABdifference.patch". Please make sure that "./Users/myname/Documents/ABdifference.patch" does not exist beforehand. Otherwise, the original file will be replaced. The patch file can use any suffix different from ".patch". The execution returns a promise, which carries no return value, but the resolve/reject signal is useful though :).

FolderBsdp.patch("./Users/myname/Documents/Afolder", "./Users/myname/Documents/Bfolder", "./Users/myname/Documents/ABdifference.patch")

In the code above, both folder A and ABdifference.patch exist beforehand. "./Users/myname/Documents/Bfolder" should not exist beforehand, to which the patching result will be written. In another word, we use the original folder A resource and the difference patch to recover B. If directory "./Users/myname/Documents/Bfolder" exists before the patch method gets executed, it will be deleted when the execution starts. The execution returns a promise. The execution returns a promise, which carries no return value, but the resolve/reject signal is useful though :).