Skip to content

Instantly share code, notes, and snippets.

View Artod's full-sized avatar
🎯
Focusing

Artem Belousov Artod

🎯
Focusing
View GitHub Profile
@Artod
Artod / flatten.js
Last active February 25, 2018 20:15
/**
* 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
@Artod
Artod / jquery.unserialize.js
Created April 11, 2012 14:20 — forked from rcmachado/jquery.unserialize.js
$.unserialize for jQuery
/**
* $.unserialize
*
* Takes a string in format "param1=value1&param2=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&param2=value2
* Return: { param1 : value1, param2: value2 }
*