Last active
August 29, 2015 14:01
-
-
Save jonathansampson/b059b74fa006e072ec7d to your computer and use it in GitHub Desktop.
Revisions
-
jonathansampson revised this gist
May 12, 2014 . 1 changed file with 20 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,39 +1,46 @@ /*global document, prompt */ (function( global ) { "use strict"; var response = { browser: { name: prompt( "Browser Name? (Chrome, IExplorer, etc)" ), version: prompt( "Browser Version? (34, 11, etc)" ) }, root: "window", properties: Object.getOwnPropertyNames( global ).sort() }; function addIfDistinct ( arr, key ) { if ( 0 > arr.indexOf( key ) ) { arr.push( key ); } } response.properties.forEach(function ( prop, index, array ) { var obj = { "property": prop }, self = global[ prop ], regex = /[a-z]+\s[A-Z][a-z]+/, props = [], proto; if ( self instanceof Object ) { proto = Object.getPrototypeOf( self ); obj.own = Object.getOwnPropertyNames( self ).sort(); while ( proto ) { Object.getOwnPropertyNames( proto ).forEach( addIfDistinct.bind( null, props ) ); proto = Object.getPrototypeOf( proto ); } obj.proto = props.sort(); if ( self.prototype ) { props = Object.getOwnPropertyNames( self.prototype ); obj[ ".prototype" ] = props.sort(); } } -
jonathansampson created this gist
May 12, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ (function ( global ) { "use strict"; var response = { browser: { name: prompt( "Browser Name" ), version: prompt( "Browser Version" ) }, root: "window", properties: Object.getOwnPropertyNames( global ).sort() }; response.properties.forEach(function ( property, index, array ) { var obj = { "property": property }, self = global[ property ], regex = /[a-z]+\s[A-Z][a-z]+/, props = [], proto; if ( self instanceof Object ) { proto = Object.getPrototypeOf( self ); obj["own"] = Object.getOwnPropertyNames( self ).sort(); while ( proto ) { Object.getOwnPropertyNames( proto ).forEach(function ( key ) { !~props.indexOf( key ) && props.push( key ); }); proto = Object.getPrototypeOf( proto ); } obj["proto"] = props.sort(); if ( self.prototype ) { props = Object.getOwnPropertyNames( self.prototype ); obj[".proto"] = props.sort(); } } array[ index ] = obj; }); document.body.textContent = JSON.stringify( response, null, 4 ); }( this ));