Last active
February 1, 2022 14:47
-
-
Save long-blade/900a8b2a133ddf10e5378db6b3a95f1c to your computer and use it in GitHub Desktop.
[Magic koa array] A simple query param array converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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