Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prettydiff

Package Overview
Dependencies
Maintainers
1
Versions
515
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettydiff - npm Package Compare versions

Comparing version 100.3.1 to 101.0.0

api/mode.ts

21

api/optionDef.ts

@@ -251,13 +251,2 @@ /*global global*/

},
end : {
api : "any",
default : 0,
definition: "The last index to process. This option is usefu" +
"l internally when recursively sliding between various libraries. The default val" +
"ue of 0 means to ignore this option.",
label : "End Index",
lexer : "any",
mode : "any",
type : "number"
},
end_comma : {

@@ -728,12 +717,2 @@ api : "any",

},
start : {
api : "any",
default : 0,
definition: "The parse table index to start working from. This is internally used for code sa" +
"mples that require switching between different libraries.",
label : "Start Index",
lexer : "any",
mode : "any",
type : "number"
},
styleguide : {

@@ -740,0 +719,0 @@ api : "any",

18

beautify/markup.ts

@@ -7,5 +7,5 @@ /*global global, prettydiff*/

lexer:string = "markup",
c:number = (options.end < 1 || options.end > data.token.length)
c:number = (prettydiff.end < 1 || prettydiff.end > data.token.length)
? data.token.length
: options.end + 1,
: prettydiff.end + 1,
lf:"\r\n"|"\n" = (options.crlf === true)

@@ -16,4 +16,4 @@ ? "\r\n"

levels:number[] = (function beautify_markup_levels():number[] {
const level:number[] = (options.start > 0)
? Array(options.start).fill(0, 0, options.start)
const level:number[] = (prettydiff.start > 0)
? Array(prettydiff.start).fill(0, 0, prettydiff.start)
: [],

@@ -398,3 +398,3 @@ nextIndex = function beautify_markup_levels_next():number {

};
let a:number = options.start,
let a:number = prettydiff.start,
comstart:number = -1,

@@ -456,2 +456,4 @@ next:number = 0,

level.push(-20);
} else if (data.types[a] === "start" && data.types[next] === "script_start") {
level.push(-10);
} else if (options.force_indent === true) {

@@ -600,3 +602,3 @@ level.push(indent);

};
let a:number = options.start,
let a:number = prettydiff.start,
external:string = "",

@@ -624,5 +626,5 @@ lastLevel:number = options.indent_level;

} else {
options.end = externalIndex[a];
prettydiff.end = externalIndex[a];
options.indent_level = lastLevel;
options.start = a;
prettydiff.start = a;
external = prettydiff.beautify[data.lexer[a]](options).replace(/\s+$/, "");

@@ -629,0 +631,0 @@ build.push(external);

@@ -9,4 +9,4 @@ /*global global, prettydiff*/

: "\n",
len:number = (options.end > 0)
? options.end + 1
len:number = (prettydiff.end > 0)
? prettydiff.end + 1
: data.token.length,

@@ -111,3 +111,3 @@ build:string[] = [],

let indent:number = options.indent_level,
a:number = options.start,
a:number = prettydiff.start,
when:string[] = ["", ""];

@@ -122,3 +122,3 @@ if (options.vertical === true && options.compressed_css === false) {

} while (a > 0);
a = options.start;
a = prettydiff.start;
}

@@ -125,0 +125,0 @@

@@ -0,4 +1,4 @@

declare var ace: any;
declare var options: any;
declare var ace: any;
declare var prettydiff: any;
declare var prettydiff: pd;
declare var window: Window;

@@ -158,3 +158,2 @@ declare module NodeJS {

definitions?: {};
}

@@ -171,2 +170,17 @@ interface performance {

}
interface pd {
(meta?): string;
api: any;
beautify: any;
end: number;
iterator: number;
meta: meta;
minify: any;
options: any,
saveAs?: Function;
scopes: scriptScopes;
sparser: any;
start: number;
version: version;
}
interface readDirectory {

@@ -198,4 +212,9 @@ callback: Function;

}
interface version {
date: string;
number: string;
parse: string;
}
interface Window {
sparser: any;
}

@@ -251,13 +251,2 @@ /*global global*/

},
end: {
api: "any",
default: 0,
definition: "The last index to process. This option is usefu" +
"l internally when recursively sliding between various libraries. The default val" +
"ue of 0 means to ignore this option.",
label: "End Index",
lexer: "any",
mode: "any",
type: "number"
},
end_comma: {

@@ -728,12 +717,2 @@ api: "any",

},
start: {
api: "any",
default: 0,
definition: "The parse table index to start working from. This is internally used for code sa" +
"mples that require switching between different libraries.",
label: "Start Index",
lexer: "any",
mode: "any",
type: "number"
},
styleguide: {

@@ -740,0 +719,0 @@ api: "any",

@@ -5,9 +5,9 @@ /*global global, prettydiff*/

const markup = function beautify_markup(options) {
const data = options.parsed, lexer = "markup", c = (options.end < 1 || options.end > data.token.length)
const data = options.parsed, lexer = "markup", c = (prettydiff.end < 1 || prettydiff.end > data.token.length)
? data.token.length
: options.end + 1, lf = (options.crlf === true)
: prettydiff.end + 1, lf = (options.crlf === true)
? "\r\n"
: "\n", externalIndex = {}, levels = (function beautify_markup_levels() {
const level = (options.start > 0)
? Array(options.start).fill(0, 0, options.start)
const level = (prettydiff.start > 0)
? Array(prettydiff.start).fill(0, 0, prettydiff.start)
: [], nextIndex = function beautify_markup_levels_next() {

@@ -392,3 +392,3 @@ let x = a + 1, y = 0;

};
let a = options.start, comstart = -1, next = 0, count = 0, indent = (isNaN(options.indent_level) === true)
let a = prettydiff.start, comstart = -1, next = 0, count = 0, indent = (isNaN(options.indent_level) === true)
? 0

@@ -458,2 +458,5 @@ : Number(options.indent_level);

}
else if (data.types[a] === "start" && data.types[next] === "script_start") {
level.push(-10);
}
else if (options.force_indent === true) {

@@ -600,3 +603,3 @@ level.push(indent);

};
let a = options.start, external = "", lastLevel = options.indent_level;
let a = prettydiff.start, external = "", lastLevel = options.indent_level;
do {

@@ -626,5 +629,5 @@ if (data.lexer[a] === lexer || prettydiff.beautify[data.lexer[a]] === undefined) {

else {
options.end = externalIndex[a];
prettydiff.end = externalIndex[a];
options.indent_level = lastLevel;
options.start = a;
prettydiff.start = a;
external = prettydiff.beautify[data.lexer[a]](options).replace(/\s+$/, "");

@@ -631,0 +634,0 @@ build.push(external);

@@ -7,4 +7,4 @@ /*global global, prettydiff*/

? "\r\n"
: "\n", len = (options.end > 0)
? options.end + 1
: "\n", len = (prettydiff.end > 0)
? prettydiff.end + 1
: data.token.length, build = [],

@@ -98,3 +98,3 @@ //a single unit of indentation

};
let indent = options.indent_level, a = options.start, when = ["", ""];
let indent = options.indent_level, a = prettydiff.start, when = ["", ""];
if (options.vertical === true && options.compressed_css === false) {

@@ -108,3 +108,3 @@ a = len;

} while (a > 0);
a = options.start;
a = prettydiff.start;
}

@@ -111,0 +111,0 @@ //beautification loop

@@ -5,9 +5,9 @@ /*global global, prettydiff*/

const markup = function minify_markup(options) {
const data = options.parsed, lexer = "markup", c = (options.end < 1 || options.end > data.token.length)
const data = options.parsed, lexer = "markup", c = (prettydiff.end < 1 || prettydiff.end > data.token.length)
? data.token.length
: options.end + 1, lf = (options.crlf === true)
: prettydiff.end + 1, lf = (options.crlf === true)
? "\r\n"
: "\n", externalIndex = {}, levels = (function minify_markup_levels() {
const level = (options.start > 0)
? Array(options.start).fill(0, 0, options.start)
const level = (prettydiff.start > 0)
? Array(prettydiff.start).fill(0, 0, prettydiff.start)
: [], nextIndex = function minify_markup_levels_next() {

@@ -77,3 +77,3 @@ let x = a + 1, y = 0;

};
let a = options.start, next = 0, comstart = -1;
let a = prettydiff.start, next = 0, comstart = -1;
// data.lines -> space before token

@@ -187,4 +187,4 @@ // level -> space after token

};
let a = options.start, b = 0, next = 0, external = "", lastLevel = 0, count = 0, linelen = 0, lines = [];
if (options.top_comments === true && data.types[a] === "comment" && options.start === 0) {
let a = prettydiff.start, b = 0, next = 0, external = "", lastLevel = 0, count = 0, linelen = 0, lines = [];
if (options.top_comments === true && data.types[a] === "comment" && prettydiff.start === 0) {
if (a > 0) {

@@ -283,5 +283,5 @@ build.push(lf);

else {
options.end = externalIndex[a];
prettydiff.end = externalIndex[a];
options.indent_level = lastLevel;
options.start = a;
prettydiff.start = a;
external = prettydiff.minify[data.lexer[a]](options).replace(/\s+$/, "");

@@ -288,0 +288,0 @@ if (options.wrap > 0 && options.minify_wrap === true) {

@@ -15,5 +15,5 @@ /*global global, prettydiff*/

? "\r\n"
: "\n", lexer = "script", invisibles = ["x;", "x}", "x{", "x(", "x)"], end = (options.end < 1 || options.end > data.token.length)
: "\n", lexer = "script", invisibles = ["x;", "x}", "x{", "x(", "x)"], end = (prettydiff.end < 1 || prettydiff.end > data.token.length)
? data.token.length
: options.end + 1, build = [], lastsemi = function minify_script_lastsemi() {
: prettydiff.end + 1, build = [], lastsemi = function minify_script_lastsemi() {
let aa = a, bb = 0;

@@ -37,4 +37,4 @@ do {

};
let a = options.start, count = 0, external = "";
if (options.top_comments === true && options.minify_keep_comments === false && data.types[a] === "comment" && options.start === 0) {
let a = prettydiff.start, count = 0, external = "";
if (options.top_comments === true && options.minify_keep_comments === false && data.types[a] === "comment" && prettydiff.start === 0) {
if (a > 0) {

@@ -120,8 +120,8 @@ build.push(lf);

} while (a < end);
options.start = skip;
options.end = a;
prettydiff.start = skip;
prettydiff.end = a;
if (a > end - 1) {
a = skip;
quit = true;
options.end = end - 2;
prettydiff.end = end - 2;
}

@@ -128,0 +128,0 @@ external = prettydiff.minify[data.lexer[a]](options).replace(/\s+$/, "");

@@ -7,8 +7,8 @@ /*global global, prettydiff*/

? "\r\n"
: "\n", len = (options.end < 1 || options.end > data.token.length)
: "\n", len = (prettydiff.end < 1 || prettydiff.end > data.token.length)
? data.token.length
: options.end + 1, build = [];
let a = options.start, b = 0, c = 0, list = [], count = 0, countx = 0;
: prettydiff.end + 1, build = [];
let a = prettydiff.start, b = 0, c = 0, list = [], count = 0, countx = 0;
//beautification loop
if (options.top_comments === true && options.minify_keep_comments === false && data.types[a] === "comment" && options.start === 0) {
if (options.top_comments === true && options.minify_keep_comments === false && data.types[a] === "comment" && prettydiff.start === 0) {
if (a > 0) {

@@ -15,0 +15,0 @@ build.push(lf);

@@ -354,3 +354,3 @@ // tests structure

qualifier: "contains",
test: `${text.green}78${text.none} matching options.`
test: `${text.green}76${text.none} matching options.`
},

@@ -357,0 +357,0 @@ {

@@ -7,5 +7,5 @@ /*global global, prettydiff*/

lexer:string = "markup",
c:number = (options.end < 1 || options.end > data.token.length)
c:number = (prettydiff.end < 1 || prettydiff.end > data.token.length)
? data.token.length
: options.end + 1,
: prettydiff.end + 1,
lf:"\r\n"|"\n" = (options.crlf === true)

@@ -16,4 +16,4 @@ ? "\r\n"

levels:number[] = (function minify_markup_levels():number[] {
const level:number[] = (options.start > 0)
? Array(options.start).fill(0, 0, options.start)
const level:number[] = (prettydiff.start > 0)
? Array(prettydiff.start).fill(0, 0, prettydiff.start)
: [],

@@ -84,3 +84,3 @@ nextIndex = function minify_markup_levels_next():number {

};
let a:number = options.start,
let a:number = prettydiff.start,
next:number = 0,

@@ -189,3 +189,3 @@ comstart:number = -1;

};
let a:number = options.start,
let a:number = prettydiff.start,
b:number = 0,

@@ -198,3 +198,3 @@ next:number = 0,

lines:string[] = [];
if (options.top_comments === true && data.types[a] === "comment" && options.start === 0) {
if (options.top_comments === true && data.types[a] === "comment" && prettydiff.start === 0) {
if (a > 0) {

@@ -288,5 +288,5 @@ build.push(lf);

} else {
options.end = externalIndex[a];
prettydiff.end = externalIndex[a];
options.indent_level = lastLevel;
options.start = a;
prettydiff.start = a;
external = prettydiff.minify[data.lexer[a]](options).replace(/\s+$/, "");

@@ -293,0 +293,0 @@ if (options.wrap > 0 && options.minify_wrap === true) {

@@ -18,5 +18,5 @@ /*global global, prettydiff*/

invisibles:string[] = ["x;", "x}", "x{", "x(", "x)"],
end:number = (options.end < 1 || options.end > data.token.length)
end:number = (prettydiff.end < 1 || prettydiff.end > data.token.length)
? data.token.length
: options.end + 1,
: prettydiff.end + 1,
build:string[] = [],

@@ -42,6 +42,6 @@ lastsemi = function minify_script_lastsemi() {

};
let a:number = options.start,
let a:number = prettydiff.start,
count:number = 0,
external:string = "";
if (options.top_comments === true && options.minify_keep_comments === false && data.types[a] === "comment" && options.start === 0) {
if (options.top_comments === true && options.minify_keep_comments === false && data.types[a] === "comment" && prettydiff.start === 0) {
if (a > 0) {

@@ -126,8 +126,8 @@ build.push(lf);

} while (a < end);
options.start = skip;
options.end = a;
prettydiff.start = skip;
prettydiff.end = a;
if (a > end - 1) {
a = skip;
quit = true;
options.end = end - 2;
prettydiff.end = end - 2;
}

@@ -134,0 +134,0 @@ external = prettydiff.minify[data.lexer[a]](options).replace(/\s+$/, "");

@@ -9,7 +9,7 @@ /*global global, prettydiff*/

: "\n",
len:number = (options.end < 1 || options.end > data.token.length)
len:number = (prettydiff.end < 1 || prettydiff.end > data.token.length)
? data.token.length
: options.end + 1,
: prettydiff.end + 1,
build:string[] = [];
let a:number = options.start,
let a:number = prettydiff.start,
b:number = 0,

@@ -22,3 +22,3 @@ c:number = 0,

//beautification loop
if (options.top_comments === true && options.minify_keep_comments === false && data.types[a] === "comment" && options.start === 0) {
if (options.top_comments === true && options.minify_keep_comments === false && data.types[a] === "comment" && prettydiff.start === 0) {
if (a > 0) {

@@ -25,0 +25,0 @@ build.push(lf);

@@ -280,13 +280,2 @@ # Pretty Diff Options

## end
property | value
-----------|---
api | any
default | 0
definition | The last index to process. This option is useful internally when recursively sliding between various libraries. The default value of 0 means to ignore this option.
label | End Index
lexer | any
mode | any
type | number
## end_comma

@@ -819,13 +808,2 @@ property | value

## start
property | value
-----------|---
api | any
default | 0
definition | The parse table index to start working from. This is internally used for code samples that require switching between different libraries.
label | Start Index
lexer | any
mode | any
type | number
## styleguide

@@ -832,0 +810,0 @@ property | value

@@ -10,3 +10,3 @@ {

"file-saver": "^1.3.8",
"sparser": "^1.1.1"
"sparser": "^1.1.3"
},

@@ -43,3 +43,3 @@ "description": "A language aware diff tool.",

},
"version": "100.3.1"
"version": "101.0.0"
}

@@ -1,7 +0,5 @@

# Pretty Diff version 100
# Pretty Diff version 101
A language aware diff, beautification, and minification tool.
## Try it out
* Current version - https://prettydiff.com/
* Prior version - https://prettydiff.com/2
## Try it out - https://prettydiff.com/

@@ -66,9 +64,9 @@ [![Build Status](https://semaphoreci.com/api/v1/prettydiff/prettydiff/branches/master/badge.svg)](https://semaphoreci.com/prettydiff/prettydiff)

### Integration
To run Pretty Diff as a utility in a third party application simply include either *js/browser.js* or *js/prettydiff.js*. Those two files are identical except for the very end where an object named `prettydiff` is assigned. Both files provide all options with defaul values assigned to an object named `prettydiff.defaults`.
To run Pretty Diff as a utility in a third party application simply include either *js/browser.js* or *js/prettydiff.js*. Those two files are identical except for the very end where an object named `prettydiff` is assigned. Both files provide all options with default values assigned to an object named `prettydiff.options`.
#### Browser
**js/browser.js** - In this file an object named `prettydiff` is assigned to the browser's *window* object. To access Pretty Diff simply call `window.prettydiff.mode(myOptions);`. The default options would be `window.prettydiff.defaults`. See the [browser demo](test/browser.html) for an example. This provides all the necessary code in a single file without any DOM bindings.
**js/browser.js** - In this file an object named `prettydiff` is assigned to the browser's *window* object. To access Pretty Diff simply call `window.prettydiff();`. The options exist as `window.prettydiff.options`. See the [browser demo](test/browser.html) for an example. This provides all the necessary code in a single file without any DOM bindings.
#### Node.js
**js/prettydiff.js** - In this file an object named `prettydiff` is assigned to Node's *module.exports*. To access Pretty Diff simply require the file: `let prettydiff = require("prettydiff");`. Default options are available as `prettydiff.defaults`. To execute simply call `prettydiff.mode(prettydiff.defaults);` where the *mode* property is the application and requires an options object.
**js/prettydiff.js** - In this file an object named `prettydiff` is assigned to Node's *module.exports*. To access Pretty Diff simply require the file: `let prettydiff = require("prettydiff");`. Default options are available as `prettydiff.options`. To execute simply call `prettydiff();`.

@@ -78,6 +76,6 @@ ```javascript

let output = "",
prettydiff = window.prettydiff.mode,
options = window.prettydiff.defaults;
prettydiff = window.prettydiff,
options = window.prettydiff.options;
options.source = "my code";
output = prettydiff(options);
output = prettydiff();
// You can include the Pretty Diff code in any way that is convenient,

@@ -90,5 +88,5 @@ // whether that is using an HTML script tag or concatenating the

prettydiff = require("prettydiff"),
options = prettydiff.defaults;
options = prettydiff.options;
options.source = "my code";
output = prettydiff.mode(options);
output = prettydiff();
// You should not have to point to the specific file.

@@ -95,0 +93,0 @@ // The js/prettydiff.js is defined as 'main' in the package.json.

@@ -6,3 +6,3 @@ import "../js/browser.js";

let prettydiff = window.prettydiff,
options = prettydiff.defaults,
options = prettydiff.options,
output = "";

@@ -14,3 +14,3 @@ options.api = "dom";

options.source = document.getElementById("input").value;
output = prettydiff.mode(options);
output = prettydiff(options);
document.getElementById("output").value = output;

@@ -17,0 +17,0 @@ };

@@ -11,2 +11,2 @@ /*prettydiff.com topcoms: true, inchar: " ", insize: 4, vertical: true */

****************************************************************************/
@carrier-logo-height:33px;@carrier-logo-width:44px;.itemResultsCard(){@arrow-size:10px;@font-size-xxs:10px;@line-height-xxs:12px;.itemResultsCard{border:1px solid @color-neutral-md-light;color:@color-black;.clearfix();.itemSummary{float:left;width:70%;.display-inline-block();}}}
@carrier-logo-height:33px;@carrier-logo-width:44px;.itemResultsCard(){@arrow-size:10px;@font-size-xxs:10px;@line-height-xxs:12px;.itemResultsCard{border:1px solid @color-neutral-md-light;color:@color-black;.itemSummary{float:left;width:70%;.display-inline-block();}}}

@@ -21,3 +21,2 @@ /*prettydiff.com topcoms: true, inchar: " ", insize: 4, vertical: true */

border: 1px solid @color-neutral-md-light;
.clearfix();
color : @color-black;

@@ -24,0 +23,0 @@

@@ -361,3 +361,3 @@

qualifier: "contains",
test: `${text.green}78${text.none} matching options.`
test: `${text.green}76${text.none} matching options.`
},

@@ -364,0 +364,0 @@ {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc