| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A diff library to compare text differences between two texts.
This is a fork of cemerick/jsdifflib which has been adapted to render the HTML on the server.
npm install node-jsdifflibjsdifflib is a Javascript library that provides:
diff(baseText, newText[, options])options
jsdifflib comes with a ready to use CSS file (assets/jsdifflib.css) or you can use a custom one.
const http = require("http");
const diff = require('node-jsdifflib');
const baseFile = "console.log(5);"
const newFile = "\"use strict\";\nconsole.log(5);";
http.createServer(function(req, res){
if (req.url === '/favicon.ico') {
res.writeHead(200, {'Content-Type': 'image/x-icon'} );
return res.end();
}
var output = diff(baseFile, newFile);
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(`<html>
<head>
<link rel="stylesheet" href="https://cdn.rawgit.com/marcosc90/node-jsdifflib/8838a6401c6933ca3faa1085bc1ec9b8174a6db8/assets/jsdifflib.css" />
</head>
<body>
${output}
</body>
</html>`);
}).listen(8081, function(){
console.log("Server started at: http://localhost:8081");
});BSD
| Back | FazBrowse Home | New Git URL |