Skip to content

DistributedWeb/dwebx-archive-file-diff

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dwebx-archive-file-diff

Get line-by-line diffs of text files in Dat archives. Basically a thin wrapper around jsdiff.

const {diffLines} = require('dwebx-archive-file-diff')

var a = new DWebXArchive('...')
var b = new DWebXArchive('...')
var diff = await diffLines(a, '/foo.txt', b, '/foo.txt')

API

diffLines (leftArchive, leftPath, rightArchive, rightPath, options)

  • Options:
    • ignoreWhitespace: true to ignore leading and trailing whitespace.
    • newlineIsToken: true to treat newline characters as separate tokens. This allows for changes to the newline structure to occur independently of the line content and to be treated as such. In general this is the more human friendly form of diffLines and diffLines is better suited for patches and other computer friendly output.
  • Returns a list of change objects (See below).

Change objects

Many of the methods above return change objects. These objects consist of the following fields:

  • value: Text content
  • added: True if the value was inserted into the new string
  • removed: True of the value was removed from the old string

Note that some cases may omit a particular flag field. Comparison on the flag fields should always be done in a truthy or falsy manner.

About

Get line-by-line diffs of text files in Dat archives

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%