index.js

/*!
 * @ecomplus/utils
 * (c) E-Com Club <[email protected]>
 * Released under the MIT License.
 */

/**
 * JS utility functions for E-Com Plus (not only) related apps.
 * {@link https://github.com/ecomclub/ecomplus-utils GitHub}
 *
 * @module @ecomplus/utils
 * @author E-Com Club <[email protected]>
 * @return {@link ecomUtils}
 * @see ecomUtils
 * @see $ecomConfig
 *
 * @example
 * // Import all utility methods with ES
 * import ecomUtils from '@ecomplus/utils'
 *
 * @example
 * // Named ES imports with some sample methods
 * import {
 *   i18n,
 *   formatMoney,
 *   minQuantity,
 *   price,
 *   // ...
 * } from '@ecomplus/utils'
 *
 * @example
 * // Import only config object
 * import { $ecomConfig } from '@ecomplus/utils'
 *
 * @example
 * // With CommonJS
 * const ecomUtils = require('@ecomplus/utils')
 *
 * @example
 * // CommonJS require standalone methods
 * const i18n = require('@ecomplus/utils/dist/methods/i18n')
 * const formatMoney = require('@ecomplus/utils/dist/methods/format-money')
 * // ...
 * // require(`@ecomplus/utils/dist/methods/${kebab-case-method-name}`)
 *
 * @example
 * <!-- Globals `ecomUtils` and `$ecomConfig` from CDN on browser -->
 * <script src="https://cdn.jsdelivr.net/npm/@ecomplus/utils/dist/ecom-utils.polyfill.min.js"></script>
 */

import { root } from './lib/globals'
import * as ecomUtils from './ecom-utils'

if (root.$ecomConfig === undefined) {
  root.$ecomConfig = ecomUtils.$ecomConfig
}

export default ecomUtils

// named exports off all methods
export * from './ecom-utils'