jonschlinkert / filter-object

Return a copy of an object, filtered to have only keys that match the given glob patterns.
MIT License
24 stars 2 forks source link

wrong behavior with negation patterns #5

Open kilianc opened 7 years ago

kilianc commented 7 years ago
const filter = require('filter-object')

console.log(filter({
  limit: 10,
  startId: 'startId',
  startKey: 'startKey',
  sort: 'sort'
}, [
  '*',
  '!sort',
  '!startId',
  '!startKey',
  '!limit'
])) // { startId: 'startId' }

console.log(filter({
  limit: 10,
  startId: 'startId',
  startKey: 'startKey',
  sort: 'sort'
}, [
  '*',
  '!sort',
  // '!startId',
  '!startKey',
  '!limit'
])) // { startId: 'startId', startKey: 'startKey' } O_O

console.log(filter({
  limit: 10,
  startId: 'startId',
  startKey: 'startKey',
  sort: 'sort'
}, [
  '*',
  '!sort',
  '',
  '!startId',
  '!startKey',
  '!limit'
])) // {} ಠ_ಠ

Are we using it wrong?

doowb commented 7 years ago

@kilianc thanks for the issue. Looks like you found a bug in glob-object. If you can submit a PR for the fix, I'd appreciate it. If not, one of us will try to get to it soon.

I'll leave this open until we get that issue fixed.