Fast ClassName Manipulation

For those tired of jQuery chaining or bothered by having multiple classLists in your code, I have ingenious solution:

function classer(elem, str) {
str.replace(/(?:\s|^)\-([^\s$]+)/g, function(m,c) {
if (!!c && elem.classList.contains(c))
elem.classList.remove(c); return '';
}).replace(/(?:\s|^)\+([^\s$]+)/g, function(m,c) {
if (!!c && !elem.classList.contains(c))
elem.classList.add(c); return '';
})
return elem;
}
//Example
classer(div, '+add_class -remove_class');

Prefix your class name with a + to add it or with a - to remove it.