grafana/public/app/core/lodash_extended.js
2016-09-14 09:17:10 +02:00

33 lines
660 B
JavaScript

define([
'lodash-src'
],
function () {
'use strict';
var _ = window._;
/*
Mixins :)
*/
_.mixin({
move: function (array, fromIndex, toIndex) {
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0]);
return array;
},
// If variable is value, then return alt. If variable is anything else, return value;
toggle: function (variable, value, alt) {
return variable === value ? alt : value;
},
toggleInOut: function(array,value) {
if(_.includes(array,value)) {
array = _.without(array,value);
} else {
array.push(value);
}
return array;
}
});
return _;
});