"use strict"; import {Utils} from "../../Utils/Utils.ecma.js"; import {Check} from "../../Utils/Check.ecma.js"; import {FormatModule} from "../FormatModule.ecma.js"; /** * @typedef {import("../FormatModule.ecma.js").FormatModule} FormatModule */ /** * @class CapitalizeFormat * @constructor * @param {!FormatModule} format * @returns {void} * @access public * @static */ export const CapitalizeFormat = (function(){ /** * @constructs CapitalizeFormat * @param {!FormatModule} format * @returns {void} * @access private * @static */ const CapitalizeFormat = function(format){ /** @type {CapitalizeFormat} */ const self = this; /** * @returns {void} * @access private */ const constructor = () => { ["Cap", "cap", "capitalize"].forEach(name => { format.modes[name] = self.get; format.checks[name] = self.check; }); }; /** * @param {!(string|Array.)} inputs * @param {!Object.} [shared = {}] * @param {!Array.} [fragments = []] * @returns {string} * @access public */ this.get = (inputs, shared = {}, fragments = []) => format.execute( Check.is_string(inputs) ? inputs : Check.is_string(inputs[0]) ? inputs[0] : "", shared, fragments).replace(/^./, character => character.toUpperCase()); /** * @param {!string} string * @param {!(string|Array.)} inputs * @param {!Object.} [shared = {}] * @param {!Array.} [fragments = []] * @returns {number} * @access public */ this.check = (string, inputs, shared = {}, fragments = []) => { /** @type {string} */ const substring = format.set_fragments_level(( Check.is_string(inputs) ? inputs : Check.is_string(inputs[0]) ? inputs[0] : ""), fragments); return ( /\{[^\{\}]+\}/.test(substring) ? format.get_check_length(string, [substring], shared, fragments, false) : FormatModule.prepare_result(string, substring, shared)); }; constructor(); }; return CapitalizeFormat; })();