sweet-data
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -0,11 +1,17 @@ | ||
var Promise = require('promise-polyfill'); | ||
var setAsap = require('setasap'); | ||
Promise._immediateFn = setAsap; | ||
var SweetData = require('../sweet-data'); | ||
function json(text) { | ||
return new Promise((resolve, reject) => { | ||
return new Promise(function(resolve, reject) { | ||
try { | ||
if (typeof text === "string") { | ||
return resolve(JSON.stringify(JSON.parse(text), null, this.step)); | ||
return resolve(JSON.stringify(JSON.parse(text), null, SweetData.SweetData.step)); | ||
} | ||
if (typeof text === "object") { | ||
return resolve(JSON.stringify(text, null, this.step)); | ||
return resolve(JSON.stringify(text, null, SweetData.SweetData.step)); | ||
} | ||
@@ -22,6 +28,6 @@ | ||
return new Promise((resolve, reject) => { | ||
return new Promise(function(resolve, reject) { | ||
try { | ||
if (typeof text === "string") { | ||
let result = JSON.stringify(JSON.parse(text)) | ||
var result = JSON.stringify(JSON.parse(text)) | ||
.replace(/\s{0,}\{\s{0,}/g, "{") | ||
@@ -46,3 +52,3 @@ .replace(/\s{0,}\[$/g, "[") | ||
if (typeof text === "object") { | ||
let result = JSON.stringify(text) | ||
var result = JSON.stringify(text) | ||
.replace(/\s{0,}\{\s{0,}/g, "{") | ||
@@ -49,0 +55,0 @@ .replace(/\s{0,}\[$/g, "[") |
@@ -0,6 +1,12 @@ | ||
var Promise = require('promise-polyfill'); | ||
var setAsap = require('setasap'); | ||
Promise._immediateFn = setAsap; | ||
var SweetData = require('../sweet-data'); | ||
function xml(text) { | ||
return new Promise((resolve, reject) => { | ||
return new Promise(function(resolve, reject) { | ||
try { | ||
let ar = text.replace(/>\s{0,}</g,"><") | ||
var ar = text.replace(/>\s{0,}</g,"><") | ||
.replace(/</g,"~::~<") | ||
@@ -19,3 +25,3 @@ .replace(/xmlns\:/g,"~::~xmlns:") | ||
if(ar[ix].search(/<!/) > -1) { | ||
str += this.shift[deep]+ar[ix]; | ||
str += SweetData.SweetData.shift[deep]+ar[ix]; | ||
inComment = true; | ||
@@ -40,23 +46,23 @@ // end comment or <![CDATA[...]]> // | ||
if(ar[ix].search(/<\w/) > -1 && ar[ix].search(/<\//) == -1 && ar[ix].search(/\/>/) == -1 ) { | ||
str = !inComment ? str += this.shift[deep++]+ar[ix] : str += ar[ix]; | ||
str = !inComment ? str += SweetData.SweetData.shift[deep++]+ar[ix] : str += ar[ix]; | ||
} else | ||
// <elm>...</elm> // | ||
if(ar[ix].search(/<\w/) > -1 && ar[ix].search(/<\//) > -1) { | ||
str = !inComment ? str += this.shift[deep]+ar[ix] : str += ar[ix]; | ||
str = !inComment ? str += SweetData.SweetData.shift[deep]+ar[ix] : str += ar[ix]; | ||
} else | ||
// </elm> // | ||
if(ar[ix].search(/<\//) > -1) { | ||
str = !inComment ? str += this.shift[--deep]+ar[ix] : str += ar[ix]; | ||
str = !inComment ? str += SweetData.SweetData.shift[--deep]+ar[ix] : str += ar[ix]; | ||
} else | ||
// <elm/> // | ||
if(ar[ix].search(/\/>/) > -1 ) { | ||
str = !inComment ? str += this.shift[deep]+ar[ix] : str += ar[ix]; | ||
str = !inComment ? str += SweetData.SweetData.shift[deep]+ar[ix] : str += ar[ix]; | ||
} else | ||
// <? xml ... ?> // | ||
if(ar[ix].search(/<\?/) > -1) { | ||
str += this.shift[deep]+ar[ix]; | ||
str += SweetData.SweetData.shift[deep]+ar[ix]; | ||
} else | ||
// xmlns // | ||
if( ar[ix].search(/xmlns\:/) > -1 || ar[ix].search(/xmlns\=/) > -1) { | ||
str += this.shift[deep]+ar[ix]; | ||
str += SweetData.SweetData.shift[deep]+ar[ix]; | ||
} | ||
@@ -78,5 +84,5 @@ | ||
return new Promise((resolve, reject) => { | ||
return new Promise(function(resolve, reject) { | ||
try { | ||
let str = preserveComments ? text | ||
var str = preserveComments ? text | ||
: text.replace(/\<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>/g,""); | ||
@@ -83,0 +89,0 @@ |
{ | ||
"name": "sweet-data", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Brian Gerhards (https://github.com/bgerhards)", | ||
@@ -42,3 +42,7 @@ "description": "plugin to pretty-print or minify XML, JSON, CSS and SQL files", | ||
"test-watch": "mocha -w" | ||
}, | ||
"dependencies": { | ||
"promise-polyfill": "^6.0.2", | ||
"setasap": "^2.0.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18618
330
2
+ Addedpromise-polyfill@^6.0.2
+ Addedsetasap@^2.0.0
+ Addedpromise-polyfill@6.1.0(transitive)
+ Addedsetasap@2.0.1(transitive)