"use strict"; import {Utils} from "../../Utils/Utils.ecma.js"; import {Check} from "../../Utils/Check.ecma.js"; /** * @typedef {import("../FormatModule.ecma.js").FormatModule} FormatModule */ /** * @class RangeFormat * @constructor * @param {!FormatModule} format * @returns {void} * @access public * @static */ export const RangeFormat = (function(){ /** * @constructs RangeFormat * @param {!FormatModule} format * @returns {void} * @access private * @static */ const RangeFormat = function(format){ /** @type {RangeFormat} */ const self = this; /** * @returns {void} * @access private */ const constructor = () => { format.modes.range = self.get; format.checks.range = self.check; }; /** * @param {!(string|Array.)} inputs * @param {!Object.} [shared = {}] * @param {!Array.} [fragments = []] * @returns {string} * @access public */ this.get = (inputs, shared = {}, fragments = []) => { if(Check.is_number(inputs = ( Check.is_string(inputs) ? Utils.get_random(inputs.split("|")).split("-").map(Number) : Check.is_array(inputs) ? inputs : []))) return "" + inputs; /** @type {number} */ const l = inputs.length; return "" + ( !l ? null : l == 1 ? inputs[0] : Utils.get_random(...inputs)); }; /** * @param {!string} string * @param {!(string|Array.)} inputs * @param {!Object.} [shared = {}] * @param {!Array.} [fragments = []] * @returns {number} * @access public */ this.check = (string, inputs, shared = {}, fragments = []) => FormatModule.check_range(string, inputs); constructor(); }; return RangeFormat; })();