Filtering object by keys in lodash : <p>I wrote the function below to return all keys in an object that match a specific pattern. It seems really round-about because there's no filter function in lodash for objects, when you use it all keys are lost. Is this the only way to filter an objects keys using lodash? </p>

<pre><code>export function keysThatMatch (pattern) {
  return (data) =&gt; {
    let x = _.chain(data)
    .mapValues((value, key) =&gt; {
      return [{
        key: key,
        value: value
      }]
    })
    .values()
    .filter(data =&gt; {
      return data[0].key.match(pattern)
    })
    .zipWith(data =&gt; {
      let tmp = {}
      tmp[data[0].key] = data[0].value
      return tmp
    })
    .value()
    return _.extend.apply(null, x)
  }
}
</code></pre>
