UNPKG

@eastsideco/escshopify

Version:

WIP JS library for Shopify, containing a variety of useful functionality.

42 lines (34 loc) 836 B
import Log from './Log'; /** * General-purpose utilties. */ class GeneralUtils { constructor() { /** @type {src/utils/Log.js~Log} */ this.Log = Log; } /** * Executes the given callback on DOMContentLoaded. * @param {function(): void} callback */ onLoad(callback) { if (document.readyState != 'loading') { callback(); } else { document.addEventListener('DOMContentLoaded', () => { callback(); }); } } /** * Create a unique key suitable for storing in localStorage, etc. * @param {String} namespace * @param {String} key * @return {String} */ safeStorageKey(namespace, key) { return '__'+namespace+'__'+key; } } /** @ignore */ export default new GeneralUtils;