lib/digitalocean/util.js
function(object) {
    // if we're not an array or object, return the primative
    if (object !== Object(object)) {
      return object;
    }

    var decamelizeString = function(string) {
      var separator = '_';
      var split = /(?=[A-Z])/;

      return string.split(split).join(separator).toLowerCase();
    };


    var output;
    if (object instanceof Array) {
      output = [];
      for(var i = 0, l = object.length; i < l; i++) {
        output.push(decamelizeKeys(object[i]));
      }
    } else {
      output = {};
      for (var key in object) {
        if (object.hasOwnProperty(key)) {
          output[decamelizeString(key)] = decamelizeKeys(object[key]);
        }
      }
    }

    return output;
  }
function(object) {
    // if we're not an array or object, return the primative
    if (object !== Object(object)) {
      return object;
    }

    var decamelizeString = function(string) {
      var separator = '_';
      var split = /(?=[A-Z])/;

      return string.split(split).join(separator).toLowerCase();
    };


    var output;
    if (object instanceof Array) {
      output = [];
      for(var i = 0, l = object.length; i < l; i++) {
        output.push(decamelizeKeys(object[i]));
      }
    } else {
      output = {};
      for (var key in object) {
        if (object.hasOwnProperty(key)) {
          output[decamelizeString(key)] = decamelizeKeys(object[key]);
        }
      }
    }

    return output;
  }
function ( object ) { // if we're not an array or object, return the primative if ( object !== Object ( object ) ) { return object ; } var decamelizeString = function ( string ) { var separator = '_' ; var split = / (?=[A-Z]) / ; return string . split ( split ) . join ( separator ) . toLowerCase ( ) ; } ; var output ; if ( object instanceof Array ) { output = [ ] ; for ( var i = 0 , l = object . length ; i < l ; i ++ ) { output . push ( decamelizeKeys ( object [ i ] ) ) ; } } else { output = { } ; for ( var key in object ) { if ( object . hasOwnProperty ( key ) ) { output [ decamelizeString ( key ) ] = decamelizeKeys ( object [ key ] ) ; } } } return output ; }
Based on Humps by Dom Christie
Based on Humps by Dom Christie