A collection of lightweight, minimal utility helper functions. This component belongs to the Joose component library, but can be used completely independently.
Please see joose for the whole component library.
To install this component independently using npm
npm install joose-utils
As of version 2, Joose Utils methods can be imported either individually or collectively:
import utils from '/path/to/node_modules/joose-utils/src/joose-utils';
import { hasClass, addClass } from '/path/to/node_modules/joose-utils/src/joose-utils';
Simply add the JavaScript onto your page either using a script tag or concatenating/bundling with your own JavaScript:
<script type="text/javascript" src="https://github.com/scoobster17/joose-utils/raw/master/path/to/node_modules/joose-utils/dist/joose-utils-es5.js"></script>
You are then good to go using the joose.utils
object available in the global namespace:
joose.utils.hasClass(elem, class);
joose.utils.toggleClass(elem, class);
hasClass(elem, class)
Check if an element has a classaddClass(elem, class)
Add a class to an elementremoveClass(elem, class)
Remove a class from an elementtoggleClass(elem, class)
Toggle whether an element has a class or notconvertStringToObject(string, arraySeparator, propertySeparator)
Convert a string to an object
(used in joose-storage for cookies)convertObjectToString(object, arraySeparator, propertySeparator)
Convert an object to a string