angular2-prettyjson
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "angular2-prettyjson", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Angular2 json utils. Includes a pipe to replace Angular's built in json pipe which implements spacing, avoids circular references. Also includes a component that will pretty print json with syntax highlight", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
# Angular 2 Pretty Json v1.0.1 | ||
# Angular 2 Pretty Json v1.0.2 | ||
@@ -3,0 +3,0 @@ A module for Angular 2 debug output of objects. Contains a pipe similar to [JsonPipe](https://angular.io/docs/ts/latest/api/common/index/JsonPipe-class.html) but adds support for spacing and handling of circular structures. |
@@ -0,0 +0,0 @@ import { PipeTransform } from "@angular/core"; |
@@ -11,20 +11,17 @@ "use strict"; | ||
}; | ||
var core_1 = require("@angular/core"); | ||
var safe_util_1 = require("./safe.util"); | ||
var SafeJsonPipe = (function () { | ||
function SafeJsonPipe() { | ||
const core_1 = require("@angular/core"); | ||
const safe_util_1 = require("./safe.util"); | ||
let SafeJsonPipe = class SafeJsonPipe { | ||
transform(obj, spaces = 2) { | ||
return JSON.stringify(obj, safe_util_1.serializer(), spaces); | ||
} | ||
SafeJsonPipe.prototype.transform = function (obj, spaces) { | ||
if (spaces === void 0) { spaces = 2; } | ||
return JSON.stringify(obj, safe_util_1.serializer(), spaces); | ||
}; | ||
SafeJsonPipe = __decorate([ | ||
core_1.Pipe({ | ||
name: "json" | ||
}), | ||
__metadata('design:paramtypes', []) | ||
], SafeJsonPipe); | ||
return SafeJsonPipe; | ||
}()); | ||
}; | ||
SafeJsonPipe = __decorate([ | ||
core_1.Pipe({ | ||
name: "json", | ||
pure: false | ||
}), | ||
__metadata('design:paramtypes', []) | ||
], SafeJsonPipe); | ||
exports.SafeJsonPipe = SafeJsonPipe; | ||
//# sourceMappingURL=json.pipe.js.map |
@@ -0,0 +0,0 @@ import { PipeTransform } from "@angular/core"; |
@@ -11,13 +11,9 @@ "use strict"; | ||
}; | ||
var core_1 = require("@angular/core"); | ||
var safe_util_1 = require("./safe.util"); | ||
var PrettyJsonPipe = (function () { | ||
function PrettyJsonPipe() { | ||
const core_1 = require("@angular/core"); | ||
const safe_util_1 = require("./safe.util"); | ||
let PrettyJsonPipe = class PrettyJsonPipe { | ||
transform(obj, spaces = 2) { | ||
return this._syntaxHighlight(obj, safe_util_1.serializer(), spaces); | ||
} | ||
PrettyJsonPipe.prototype.transform = function (obj, spaces) { | ||
if (spaces === void 0) { spaces = 2; } | ||
return this._syntaxHighlight(obj, safe_util_1.serializer(), spaces); | ||
}; | ||
PrettyJsonPipe.prototype._syntaxHighlight = function (json, serializer, spacing) { | ||
// Credits to the accepted answer here http://stackoverflow.com/questions/4810841/how-can-i-pretty-print-json-using-javascript | ||
_syntaxHighlight(json, serializer, spacing) { | ||
if (typeof json !== "string") { | ||
@@ -28,3 +24,3 @@ json = JSON.stringify(json, serializer, spacing); | ||
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { | ||
var cls = "number"; | ||
let cls = "number"; | ||
if (/^"/.test(match)) { | ||
@@ -44,14 +40,14 @@ if (/:$/.test(match)) { | ||
} | ||
return "<span class=\"" + cls + "\">" + match + "</span>"; | ||
return `<span class="${cls}">${match}</span>`; | ||
}); | ||
}; | ||
PrettyJsonPipe = __decorate([ | ||
core_1.Pipe({ | ||
name: "prettyjson" | ||
}), | ||
__metadata('design:paramtypes', []) | ||
], PrettyJsonPipe); | ||
return PrettyJsonPipe; | ||
}()); | ||
} | ||
}; | ||
PrettyJsonPipe = __decorate([ | ||
core_1.Pipe({ | ||
name: "prettyjson", | ||
pure: false | ||
}), | ||
__metadata('design:paramtypes', []) | ||
], PrettyJsonPipe); | ||
exports.PrettyJsonPipe = PrettyJsonPipe; | ||
//# sourceMappingURL=prettyjson.pipe.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
34033
21
670