Skip to content

Instantly share code, notes, and snippets.

View mihaimetal's full-sized avatar

Michael mihaimetal

  • Bucharest
View GitHub Profile
@mihaimetal
mihaimetal / flattenArr.js
Created January 26, 2016 14:01
Flatten Array Deep
const flattenArray = function(arr, res){
res = res || [];
arr.forEach((val) => {
if(Array.isArray(val)){
flattenArray(val, res);
} else {
res.push(val);
}
});
return res;
// example: style="width:{{math 70 '+' 5 '*' numProfiles '+' '%'}}"
// Handlebars.registerHelper("math", BasicMathOperations);
function BasicMathOperations() {
var args = Array.prototype.slice.call(arguments);
var options = args.pop();
function performOperation(lvalue, operator, rvalue){
lvalue = parseFloat(lvalue) || lvalue; //?
rvalue = parseFloat(rvalue) || rvalue; //?
return {