lib/helpers.js
function (obj) {
    // sanity check
    if (!obj || typeof obj !== 'object') {
      return []
    }

    var results = []

    Object.keys(obj).forEach(function (name) {
      // nested values in query string
      if (typeof obj[name] === 'object') {
        obj[name].forEach(function (value) {
          results.push({
            name: name,
            value: value
          })
        })
        return
      }

      results.push({
        name: name,
        value: obj[name]
      })
    })

    return results
  }
function (obj) {
    // sanity check
    if (!obj || typeof obj !== 'object') {
      return []
    }

    var results = []

    Object.keys(obj).forEach(function (name) {
      // nested values in query string
      if (typeof obj[name] === 'object') {
        obj[name].forEach(function (value) {
          results.push({
            name: name,
            value: value
          })
        })
        return
      }

      results.push({
        name: name,
        value: obj[name]
      })
    })

    return results
  }
function ( obj ) { // sanity check if ( ! obj || typeof obj !== 'object' ) { return [ ] } var results = [ ] Object . keys ( obj ) . forEach ( function ( name ) { // nested values in query string if ( typeof obj [ name ] === 'object' ) { obj [ name ] . forEach ( function ( value ) { results . push ( { name : name , value : value } ) } ) return } results . push ( { name : name , value : obj [ name ] } ) } ) return results }
Transform objects into an array of key value pairs.
Transform objects into an array of key value pairs .