Skip to content

Instantly share code, notes, and snippets.

@jonathansampson
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save jonathansampson/9418482 to your computer and use it in GitHub Desktop.

Select an option

Save jonathansampson/9418482 to your computer and use it in GitHub Desktop.

Revisions

  1. jonathansampson revised this gist Mar 8, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Proto-Crawler.js
    Original file line number Diff line number Diff line change
    @@ -19,4 +19,4 @@ var output = (function ( object ) {

    /* Choose how you'd like it output */
    document.body.style.whiteSpace = "pre";
    document.body.textContent = JSON.stringify( output, null, "\t" );
    document.body.textContent = JSON.stringify( output, null, "\t" );
  2. jonathansampson revised this gist Mar 8, 2014. 1 changed file with 10 additions and 17 deletions.
    27 changes: 10 additions & 17 deletions Proto-Crawler.js
    Original file line number Diff line number Diff line change
    @@ -2,27 +2,20 @@ var output = (function ( object ) {

    "use strict";

    var names = [];
    var props = Object.getOwnPropertyNames( object );
    var proto = Object.getPrototypeOf( object );

    while ( proto ) {
    names = Object.getOwnPropertyNames( proto );
    for ( var i = 0; i < names.length; i++ ) {
    if ( props.indexOf( names[i] ) < 0 ) {
    props.push( names[i] );
    }
    }
    proto = Object.getPrototypeOf( proto );
    function getProperties ( object ) {
    return object ? Object.getOwnPropertyNames( object )
    .concat( getProperties( Object.getPrototypeOf( object ) ) ) : [] ;
    }

    props = props.sort(function ( a, b ) {
    return a < b ? -1 : a > b ? 1 : 0;
    });
    function getUnique ( array ) {
    return array.filter(function ( value, index ) {
    return array.lastIndexOf( value ) === index;
    });
    }

    return props;
    return getUnique( getProperties( object ).sort() );

    }( this ));
    }( window ));

    /* Choose how you'd like it output */
    document.body.style.whiteSpace = "pre";
  3. jonathansampson revised this gist Mar 7, 2014. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions Proto-Crawler.js
    Original file line number Diff line number Diff line change
    @@ -17,8 +17,6 @@ var output = (function ( object ) {
    }

    props = props.sort(function ( a, b ) {
    a = a.toLowerCase();
    b = b.toLowerCase();
    return a < b ? -1 : a > b ? 1 : 0;
    });

  4. jonathansampson revised this gist Mar 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Proto-Crawler.js
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ var output = (function ( object ) {

    return props;

    }( window ));
    }( this ));

    /* Choose how you'd like it output */
    document.body.style.whiteSpace = "pre";
  5. jonathansampson renamed this gist Mar 7, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. jonathansampson created this gist Mar 7, 2014.
    31 changes: 31 additions & 0 deletions Proto-Crawler
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    var output = (function ( object ) {

    "use strict";

    var names = [];
    var props = Object.getOwnPropertyNames( object );
    var proto = Object.getPrototypeOf( object );

    while ( proto ) {
    names = Object.getOwnPropertyNames( proto );
    for ( var i = 0; i < names.length; i++ ) {
    if ( props.indexOf( names[i] ) < 0 ) {
    props.push( names[i] );
    }
    }
    proto = Object.getPrototypeOf( proto );
    }

    props = props.sort(function ( a, b ) {
    a = a.toLowerCase();
    b = b.toLowerCase();
    return a < b ? -1 : a > b ? 1 : 0;
    });

    return props;

    }( window ));

    /* Choose how you'd like it output */
    document.body.style.whiteSpace = "pre";
    document.body.textContent = JSON.stringify( output, null, "\t" );