Skip to content

Instantly share code, notes, and snippets.

@long-blade
Last active February 1, 2022 14:47
Show Gist options
  • Save long-blade/900a8b2a133ddf10e5378db6b3a95f1c to your computer and use it in GitHub Desktop.
Save long-blade/900a8b2a133ddf10e5378db6b3a95f1c to your computer and use it in GitHub Desktop.
[Magic koa array] A simple query param array converter
const toMagicArray = x => (Array.isArray(x) ? x : x.split(',')).filter(y => y);
// input: '56' output: ['56']
// input: ['56', '6'] output: ['56', '6']
// input: 56,6,3 output: ['56', '6', '3']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment