Skip to content

Instantly share code, notes, and snippets.

@moleike
Last active September 19, 2016 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moleike/874924380a6ff213dd38ec26bc750388 to your computer and use it in GitHub Desktop.
Save moleike/874924380a6ff213dd38ec26bc750388 to your computer and use it in GitHub Desktop.
const parseAttributes = payload => payload
.split(',')
.map(pair => pair.split('='))
.filter(pair => pair.length === 2)
.map(([key,val]) => ({ [key]: val }))
// > parseAttributes('pmin=5,pmax=40')
// [ { pmin: '5' }, { pmax: '40' } ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment