Skip to content

Commit

Permalink
Merge pull request #60 from cozyazure/master
Browse files Browse the repository at this point in the history
use constructor.name property by default for custom name, if defined
  • Loading branch information
mohsen1 committed Aug 27, 2016
2 parents 70da0b6 + 4a3b930 commit 4351176
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/json-formatter.css
@@ -1,7 +1,7 @@
/*!
* jsonformatter
*
* Version: 0.6.0 - 2016-04-29T03:24:40.680Z
* Version: 0.6.0 - 2016-08-27T12:58:03.339Z
* License: Apache-2.0
*/

Expand Down
8 changes: 7 additions & 1 deletion dist/json-formatter.js
@@ -1,7 +1,7 @@
/*!
* jsonformatter
*
* Version: 0.6.0 - 2016-04-29T03:24:40.672Z
* Version: 0.6.0 - 2016-08-27T12:58:03.306Z
* License: Apache-2.0
*/

Expand Down Expand Up @@ -65,6 +65,12 @@ angular.module('jsonFormatter', ['RecursionHelper'])
if (typeof object === 'object' && !object.constructor) {
return 'Object';
}

//ES6 default gives name to constructor
if (object.__proto__ !== undefined && object.__proto__.constructor !== undefined && object.__proto__.constructor.name !== undefined) {
return object.__proto__.constructor.name;
}

var funcNameRegex = /function (.{1,})\(/;
var results = (funcNameRegex).exec((object).constructor.toString());
if (results && results.length > 1) {
Expand Down
2 changes: 1 addition & 1 deletion dist/json-formatter.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/json-formatter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/json-formatter.js
Expand Up @@ -57,6 +57,12 @@ angular.module('jsonFormatter', ['RecursionHelper'])
if (typeof object === 'object' && !object.constructor) {
return 'Object';
}

//ES6 default gives name to constructor
if (object.__proto__ !== undefined && object.__proto__.constructor !== undefined && object.__proto__.constructor.name !== undefined) {
return object.__proto__.constructor.name;
}

var funcNameRegex = /function (.{1,})\(/;
var results = (funcNameRegex).exec((object).constructor.toString());
if (results && results.length > 1) {
Expand Down

0 comments on commit 4351176

Please sign in to comment.