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

sweet-data

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sweet-data - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

18

lib/json/index.js

@@ -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"
}
}
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