Skip to content

Commit 4351176

Browse files
authored
Merge pull request #60 from cozyazure/master
use constructor.name property by default for custom name, if defined
2 parents 70da0b6 + 4a3b930 commit 4351176

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

dist/json-formatter.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* jsonformatter
33
*
4-
* Version: 0.6.0 - 2016-04-29T03:24:40.680Z
4+
* Version: 0.6.0 - 2016-08-27T12:58:03.339Z
55
* License: Apache-2.0
66
*/
77

dist/json-formatter.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* jsonformatter
33
*
4-
* Version: 0.6.0 - 2016-04-29T03:24:40.672Z
4+
* Version: 0.6.0 - 2016-08-27T12:58:03.306Z
55
* License: Apache-2.0
66
*/
77

@@ -65,6 +65,12 @@ angular.module('jsonFormatter', ['RecursionHelper'])
6565
if (typeof object === 'object' && !object.constructor) {
6666
return 'Object';
6767
}
68+
69+
//ES6 default gives name to constructor
70+
if (object.__proto__ !== undefined && object.__proto__.constructor !== undefined && object.__proto__.constructor.name !== undefined) {
71+
return object.__proto__.constructor.name;
72+
}
73+
6874
var funcNameRegex = /function (.{1,})\(/;
6975
var results = (funcNameRegex).exec((object).constructor.toString());
7076
if (results && results.length > 1) {

dist/json-formatter.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/json-formatter.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/json-formatter.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ angular.module('jsonFormatter', ['RecursionHelper'])
5757
if (typeof object === 'object' && !object.constructor) {
5858
return 'Object';
5959
}
60+
61+
//ES6 default gives name to constructor
62+
if (object.__proto__ !== undefined && object.__proto__.constructor !== undefined && object.__proto__.constructor.name !== undefined) {
63+
return object.__proto__.constructor.name;
64+
}
65+
6066
var funcNameRegex = /function (.{1,})\(/;
6167
var results = (funcNameRegex).exec((object).constructor.toString());
6268
if (results && results.length > 1) {

0 commit comments

Comments
 (0)