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

gts-snapsync-node

v1.1.3

Published

An excellent library and toolset for optimized transfers of single files and directory snapshots based on librsync.

Downloads

6

Readme

snapsync

An excellent library and toolset for optimized transfers of single files and directory snapshots based on librsync.

npm downloads total npm version npm license

librsync helps with the efficient calculation of the differences between two files. The rsync algorithm is different from most differencing algorithms because it does not require the presence of the two files to calculate the delta. Instead, it requires a set of checksums of each block of one file, which together form a signature for that file. Blocks at any in the other file which have the same checksum are likely to be identical, and whatever remains is the difference.

Installation

Install the snapsync module via

npm install gts-snapsync --save

or

yarn add snapsync

This npm-library provides prebuilt binaries for a particular set of platforms with the help of node-pre-gyp and node-pre-gyp-github. In case there are no prebuilt binaries for your platform, the installation procedure tries to fall back to building the library from source code. Building from source code requires further dependencies which cannot be provided via NPM. Therefore building from source code will fail in this context. If you want to build the module for your architecture, please follow these instructions. Or create a ticket stating your requirements and I will include your architecture in our regular builds ASAP.

Usage

Synchronize Files

Scenario: You have two devices (A and B) each storing a different version of a particular file, and you want to update the version on device B to the version provided in device A.

var snapsync = require('gts-snapsync');

// API:
// 1) snapsync.sync.signature(<base:in>, <signature:out> [, block-length] [, sum-length])
// 2) snapsync.sync.delta(<signature:in>, <target:in>, <patch:out>)
// 3) snapsync.sync.patch(<patch:in>, <base:in>, <target:out>)

// on device B: create signature file (and copy it to device A)
snapsync.sync.signature('bin-v1', 'bin-v1.sig', 0, 8);

// on device A: create patch file (and copy it to device B)
snapsync.sync.delta('bin-v1.sig', 'bin-v2', 'bin-v1v2.patch');

// on device B: apply patch file to old version to generate new version
snapsync.sync.patch('bin-v1v2.patch', 'bin-v1', 'bin-v2');

Note: You can use this procedure with any filetype. In case you are planning to use archive files like tar or zip to synchronize directory structures, please use our optimized file format instead (see below).

Packing and Unpacking Directory Structures

The archive format provided by the snapsync.snap tool is optimized for the signature, delta and patch cycle provided by snapsync.sync. It works with recursive directory structures and stores filenames, access bitmasks and content of files. Additionally it sorts directories while creating the image file to avoid unnecessary deltas during the synchronization phase.

var snapsync = require('snapsync');

// API:
// 1) snapsync.snap.create(<directory:in>, <image:out>)
// 2) snapsync.snap.extract(<image:in>, <directory:out>)

// create image
snapsync.snap.create('my-data', 'my-data.img');

// extract image
snapsync.snap.extract('my-data.img', 'my-data');