Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

added option to sort object keys when inspecting an object #24

Open
wants to merge 5 commits into from

1 participant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 3, 2012
  1. @gabesoft
Commits on Dec 7, 2012
  1. @gabesoft

    version update

    gabesoft authored
  2. @gabesoft

    Revert "version update"

    gabesoft authored
    This reverts commit 78250c4.
Commits on Apr 22, 2013
  1. made sort object keys configurable

    Gabriel Adomnicai authored
  2. readme fix

    Gabriel Adomnicai authored
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 0 deletions.
  1. +1 −0  README.md
  2. +4 −0 lib/eyes.js
View
1  README.md
@@ -57,6 +57,7 @@ These are the default styles and settings used by _eyes_.
},
pretty: true, // Indent object literals
+ sortObjectKeys: false, // Sort object keys
hideFunctions: false, // Don't output functions at all
stream: process.stdout, // Stream to write to, or null
maxLength: 2048 // Truncate output if longer
View
4 lib/eyes.js
@@ -27,6 +27,7 @@ eyes.defaults = {
regexp: 'green', // /\d+/
},
pretty: true, // Indent object literals
+ sortObjectKeys: false, // Sort object keys
hideFunctions: false,
showHidden: false,
stream: process.stdout,
@@ -178,6 +179,9 @@ function stringifyObject(obj, options, level) {
var ws = pretty ? '\n' + new(Array)(level * 4 + 1).join(' ') : ' ';
var keys = options.showHidden ? Object.keys(obj) : Object.getOwnPropertyNames(obj);
+ if (options.sortObjectKeys) {
+ keys = keys.sort();
+ }
keys.forEach(function (k) {
if (Object.prototype.hasOwnProperty.call(obj, k)
&& !(obj[k] instanceof Function && options.hideFunctions)) {
Something went wrong with that request. Please try again.