This file contains hidden or 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
| /** | |
| * Flatten an array of arbitrarily nested arrays of integers | |
| * into a flat array of integers. | |
| * @param {Array} arr - Arbitrarily nested Arrays of Numbers | |
| * @return {Array} - Array of Numbers | |
| */ | |
| const flatten = (arr) => arr.reduce((flat, next) => flat.concat(Array.isArray(next) ? flatten(next) : next), []) | |
| export default flatten |
This file contains hidden or 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
| /** | |
| * $.unserialize | |
| * | |
| * Takes a string in format "param1=value1¶m2=value2" and returns an object { param1: 'value1', param2: 'value2' }. If the "param1" ends with "[]" the param is treated as an array. | |
| * | |
| * Example: | |
| * | |
| * Input: param1=value1¶m2=value2 | |
| * Return: { param1 : value1, param2: value2 } | |
| * |