New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

jsdifflib

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

jsdifflib

A javascript library for diffing text and generating corresponding HTML views

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

jsdifflib

A javascript library for diffing text and generating corresponding HTML views. This is a fork of cemerick/jsdifflib which has been updated for use with browserify and node.js

NPM version

Installation

npm install jsdifflib

Overview

jsdifflib is a Javascript library that provides:

  • a partial reimplementation of Python’s difflib module (specifically, the SequenceMatcher class)
  • a visual diff view generator, that offers side-by-side as well as inline formatting of file data

It puts data in a simple table that can be easilly re-styled using CSS

jsdifflib does not require jQuery or any other Javascript library.

Example

var difflib = require('jsdifflib');

function getDiff(baseTextRaw, newTextRaw) {
  // build the diff view and return a DOM node
  return diffview.buildView({
      baseText: baseText,
      newText: newText,
      // set the display titles for each resource
      baseTextName: "Base Text",
      newTextName: "New Text",
      contextSize: 10,
      //set inine to true if you want inline
      //rather than side by side diff
      inline: true
  });
}

document.body.appendChild(getDiff('source', 'destination'));

License

BSD

FAQs

Package last updated on 27 Sep 2013

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