@vertigis/arcgis-extensions 47.0.1 → 47.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AccessDeniedError.js +1 -1
- package/AppConfig.schema.json +6 -2
- package/NotFoundError.js +1 -1
- package/data/ArcGISServiceTableExtension.js +1 -1
- package/data/Feature.d.ts +7 -7
- package/data/Feature.js +1 -1
- package/data/FeatureList.js +1 -1
- package/data/FeatureSaveError.js +1 -1
- package/data/FieldExtension.js +1 -1
- package/data/Schema.js +1 -1
- package/data/convert.d.ts +6 -2
- package/data/convert.js +1 -1
- package/docs/html/assets/navigation.js +1 -1
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/data_Feature.Feature.html +6 -6
- package/docs/html/classes/support_FormatSettings.FormatSettings.html +10 -5
- package/docs/html/classes/support_Serializable.SerializableBase.html +1 -1
- package/docs/html/classes/utilities_Time.Time.html +11 -0
- package/docs/html/classes/{utilities_date.DateFormatter.html → utilities_format_date.DateFormatter.html} +57 -56
- package/docs/html/classes/{utilities_number.NumberFormatter.html → utilities_format_number.NumberFormatter.html} +54 -54
- package/docs/html/classes/utilities_format_string.StringFormatter.html +49 -0
- package/docs/html/classes/utilities_format_time.TimeFormatter.html +137 -0
- package/docs/html/enums/{utilities_date.DateFormat.html → utilities_format_formats.DateFormat.html} +12 -11
- package/docs/html/enums/{utilities_number.NumberFormat.html → utilities_format_formats.NumberFormat.html} +9 -8
- package/docs/html/enums/utilities_format_formats.TimeFormat.html +16 -0
- package/docs/html/functions/utilities_field.isNumericFieldType.html +1 -0
- package/docs/html/functions/{utilities_date.ERR_TIME_ZONE_INVALID.html → utilities_format_date.ERR_TIME_ZONE_INVALID.html} +1 -1
- package/docs/html/functions/{utilities_date.esriFormatToGeocortexFormat.html → utilities_format_date.esriFormatToGeocortexFormat.html} +2 -2
- package/docs/html/functions/{utilities_date.format.html → utilities_format_date.format.html} +3 -3
- package/docs/html/functions/{utilities_date.isValid.html → utilities_format_date.isValid.html} +1 -1
- package/docs/html/functions/{utilities_date.isValidTimeZone.html → utilities_format_date.isValidTimeZone.html} +1 -1
- package/docs/html/functions/{utilities_date.parse.html → utilities_format_date.parse.html} +3 -3
- package/docs/html/functions/{utilities_date.parseUtc.html → utilities_format_date.parseUtc.html} +3 -3
- package/docs/html/functions/{utilities_number.format.html → utilities_format_number.format.html} +3 -3
- package/docs/html/functions/{utilities_number.parse.html → utilities_format_number.parse.html} +3 -3
- package/docs/html/functions/{utilities_string.format.html → utilities_format_string.format.html} +3 -3
- package/docs/html/functions/utilities_format_time.esriFormatToGeocortexFormat.html +5 -0
- package/docs/html/functions/utilities_format_time.format.html +9 -0
- package/docs/html/functions/utilities_format_time.parse.html +15 -0
- package/docs/html/hierarchy.html +1 -1
- package/docs/html/interfaces/data_Feature.FormatOptions.html +21 -13
- package/docs/html/interfaces/data_convert.FromCsvOptions.html +6 -3
- package/docs/html/interfaces/data_convert.FromShapefileOptions.html +6 -3
- package/docs/html/interfaces/data_convert.FromXLSXOptions.html +6 -3
- package/docs/html/interfaces/data_convert.ToCsvOptions.html +6 -3
- package/docs/html/interfaces/data_convert.ToShapefileOptions.html +6 -3
- package/docs/html/interfaces/data_convert.ToXLSXOptions.html +6 -3
- package/docs/html/interfaces/data_convert.UploadDataOptions.html +6 -3
- package/docs/html/interfaces/json_FeatureLayerJson.FeatureLayerJson.html +2 -2
- package/docs/html/interfaces/json_StreamLayerJson.StreamLayerJson.html +2 -2
- package/docs/html/interfaces/mapping_FeatureLayerExtension.FeatureLayerProperties.html +2 -2
- package/docs/html/interfaces/mapping_FeatureLayerExtensionBase.FeatureLayerBaseProperties.html +2 -2
- package/docs/html/interfaces/support_FormatSettings.FormatSettingsProperties.html +10 -6
- package/docs/html/interfaces/utilities_format_FormatSettings.FormatSettings.html +21 -0
- package/docs/html/interfaces/{utilities_date.DateFormatterProperties.html → utilities_format_date.DateFormatterProperties.html} +12 -11
- package/docs/html/interfaces/{utilities_date.DateSettings.html → utilities_format_date.DateSettings.html} +6 -5
- package/docs/html/interfaces/utilities_format_date.FormatOptions.html +12 -0
- package/docs/html/interfaces/utilities_format_date.ParseOptions.html +14 -0
- package/docs/html/interfaces/{utilities_number.FormatOptions.html → utilities_format_number.FormatOptions.html} +9 -8
- package/docs/html/interfaces/{utilities_number.NumberFormatterProperties.html → utilities_format_number.NumberFormatterProperties.html} +13 -13
- package/docs/html/interfaces/{utilities_number.NumberSettings.html → utilities_format_number.NumberSettings.html} +7 -7
- package/docs/html/interfaces/{utilities_number.ParseOptions.html → utilities_format_number.ParseOptions.html} +4 -4
- package/docs/html/interfaces/utilities_format_string.FormatOptions.html +30 -0
- package/docs/html/interfaces/utilities_format_time.FormatOptions.html +7 -0
- package/docs/html/interfaces/utilities_format_time.ParseOptions.html +9 -0
- package/docs/html/interfaces/utilities_format_time.TimeFormatterProperties.html +14 -0
- package/docs/html/interfaces/utilities_format_time.TimeSettings.html +10 -0
- package/docs/html/interfaces/utilities_log.LogOptions.html +16 -12
- package/docs/html/modules/utilities_FormatSettings.html +3 -3
- package/docs/html/modules/utilities_Time.html +2 -0
- package/docs/html/modules/utilities_date.html +18 -18
- package/docs/html/modules/utilities_format_FormatSettings.html +3 -0
- package/docs/html/modules/utilities_format__utils.html +1 -0
- package/docs/html/modules/utilities_format_date.html +16 -0
- package/docs/html/modules/utilities_format_formats.html +4 -0
- package/docs/html/modules/utilities_format_number.html +9 -0
- package/docs/html/modules/utilities_format_string.html +5 -0
- package/docs/html/modules/utilities_format_time.html +11 -0
- package/docs/html/modules/utilities_number.html +11 -11
- package/docs/html/modules/utilities_string.html +5 -5
- package/docs/html/types/json_FieldJson.FieldJsonType.html +1 -1
- package/docs/html/types/json_PopupInfoJson.DateFormatJsonType.html +1 -1
- package/docs/html/variables/utilities_format_FormatSettings.settings.html +3 -0
- package/docs/html/variables/{utilities_date.DEFAULT_PARSING_FORMATS.html → utilities_format_date.DEFAULT_PARSING_FORMATS.html} +1 -1
- package/docs/html/variables/{utilities_date.INVALID_DATE.html → utilities_format_date.INVALID_DATE.html} +1 -1
- package/docs/html/variables/{utilities_date.settings.html → utilities_format_date.settings.html} +1 -1
- package/docs/html/variables/{utilities_FormatSettings.settings.html → utilities_format_number.settings.html} +1 -2
- package/docs/html/variables/utilities_format_time.DEFAULT_PARSING_FORMATS.html +2 -0
- package/docs/html/variables/{utilities_number.settings.html → utilities_format_time.settings.html} +1 -1
- package/docs/html/variables/version.version.html +1 -1
- package/json/FieldJson.d.ts +1 -1
- package/json/PopupInfoJson.d.ts +1 -1
- package/locale/language.d.ts +1 -1
- package/locale/language.js +1 -1
- package/mapping/ArcGISSublayerExtension.js +1 -1
- package/mapping/FeatureLayerExtensionBase.js +1 -1
- package/mapping/SubtypeGroupLayerExtension.js +1 -1
- package/mapping/SubtypeSublayerExtension.js +1 -1
- package/mapping/_SublayerExtension.js +1 -1
- package/mapping/support/featureService.js +1 -1
- package/package.json +3 -2
- package/portal/Field.d.ts +1 -1
- package/portal/Field.js +1 -1
- package/portal/Format.d.ts +2 -2
- package/support/FormatSettings.d.ts +21 -7
- package/support/FormatSettings.js +1 -1
- package/support/InitializeError.js +1 -1
- package/tasks/identify/IdentifyError.js +1 -1
- package/tasks/query/QueryError.js +1 -1
- package/tasks/search/SearchError.js +1 -1
- package/tasks/search/_utilities.js +1 -1
- package/tasks/search/support/_querySearchProviderUtils.js +1 -1
- package/utilities/FormatSettings.d.ts +6 -31
- package/utilities/FormatSettings.js +1 -1
- package/utilities/GeometryServiceError.js +1 -1
- package/utilities/Time.d.ts +22 -0
- package/utilities/Time.js +1 -0
- package/utilities/_wkt.js +1 -1
- package/utilities/date.d.ts +35 -349
- package/utilities/date.js +1 -1
- package/utilities/field.d.ts +2 -0
- package/utilities/field.js +1 -1
- package/utilities/format/FormatSettings.d.ts +41 -0
- package/utilities/format/FormatSettings.js +1 -0
- package/utilities/format/_utils.d.ts +1 -0
- package/utilities/format/_utils.js +1 -0
- package/utilities/format/date.d.ts +336 -0
- package/utilities/format/date.js +1 -0
- package/utilities/format/formats.d.ts +127 -0
- package/utilities/format/formats.js +1 -0
- package/utilities/format/number.d.ts +193 -0
- package/utilities/format/number.js +1 -0
- package/utilities/format/string.d.ts +96 -0
- package/utilities/format/string.js +1 -0
- package/utilities/format/time.d.ts +206 -0
- package/utilities/format/time.js +1 -0
- package/utilities/log.d.ts +2 -2
- package/utilities/number.d.ts +25 -218
- package/utilities/number.js +1 -1
- package/utilities/string.d.ts +16 -81
- package/utilities/string.js +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/docs/html/classes/utilities_string.StringFormatter.html +0 -42
- package/docs/html/interfaces/utilities_FormatSettings.FormatSettings.html +0 -17
- package/docs/html/interfaces/utilities_date.FormatOptions.html +0 -9
- package/docs/html/interfaces/utilities_date.ParseOptions.html +0 -11
- package/docs/html/interfaces/utilities_string.FormatOptions.html +0 -22
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__decorate as t}from"tslib";import{getMatchingLocales as r,get as e,INVARIANT as i}from"../../locale.js";import{serializable as a,SerializableBase as n}from"../../support/Serializable.js";import{checkArg as s}from"../checkArg.js";import{settings as o}from"./FormatSettings.js";import{NumberFormat as m}from"./formats.js";const c=[" ",String.fromCharCode(160),String.fromCharCode(8239)],l=/[%٪%٪]/g,u=/₩|¥|元|レイ|₾|₽|₼|₺|₹|₸|₴|₲|₱|₮|₭|€|₫|₪|₩|₧|₦|₤IT|₡|CN¥|PTE||៛|የቻይና ዩዋን|ብር|ლ|฿|සිෆ්එ|රු\.|ಲೀ|રૂ\.|৳|लेई|रू|नेरू|ل\.ل\.|ل\.س\.|ریال|ر\.ي\.|ر\.ق\.|ر\.ع\.|ر\.س\.|ر\.إ\.|د\.م\.|د\.ل\.|د\.ك\.|د\.ع\.|د\.س\.|د\.ج\.|د\.ت\.|د\.ب\.|د\.إ\.|د\.أ\.|ج\.م\.|ج\.س\.|أ\.م\.|؋|ל״י|֏|щ\.д\.|сом|руб\.|руб|р\.|лв\.|крб\.|кр|ден|ТМТ|КМ|Δρχ|öS|Íkr|¥CN|¥|£MT|£LB|£L|£IL|£IE|£GI|£GB|£FK|£E|£CY|£|zł|zl|soʻm|rb|r\.|p\.|mk|ley|leu|lej|lei|kr\.|kr|kn|din\.|den|Zł|ZWR|ZWL|ZWD|ZRZ|ZRN|ZMW|ZMK|ZK|ZAR|ZAL|YUR|YUN|YUM|YUD|YER|YDD|XXXX|XXX|XUA|XTS|XSU|XRE|XPT|XPF|XPD|XOF|XFU|XFO|XEU|XDR|XCD|XBD|XBC|XBB|XBA|XAU|XAG|XAF|WST|WS\$|VUV|VT|VNN|VND|VEF|VEB|UZS|UYU|UYP|UYI|UY\$|USh|USS|USN|USD|US\$|UM|UK£|UGX|UGS|UAK|UAH|Tk|TZS|TWD|TTD|TT\$|TSh|TRY|TRL|TPE|TOP|TND|TMT|TMM|TK|TJS|TJR|THB|T\$|S£|SZL|SYP|SVC|SUR|STN|STD|SSP|SRG|SRD|SR\$|SR|SOS|SLL|SKK|SIT|SI\$|SHP|SGD|SEK|SD£|SDP|SDG|SDD|SCR|SBD|SB\$|SAR|S\/|S\$|S|Rs\.|Rs|Rp|RWF|RUR|RUB|RSD|RON|ROL|RM|RHD|RF|RD\$|R\$|R|QAR|Q|PYG|PTE|PLZ|PLN|PKR|PHP|PGK|PES|PEN|PEI|PAB|P\.|P|OMR|Nkr|Nfk|NZD\$|NZD|NZ\$|NT\$|NPR|NOK|NLG|NKr|NIS|NIO|NIC|NGN|NAf\.|NAf|NAD|N\$|MZN|MZM|MZE|MYR|MXV|MXP|MXN|MX\$|MWK|MVR|MVP|MUR|MTn|MTP|MTL|MRO|MOP\$|MOP|MNT|MMK|MLF|MKN|MKD|MK|MGF|MGA|MDL|MDC|MCF|MAF|MAD|L£|Lt|Ls|Lekë|Le|LYD|LVR|LVL|LUL|LUF|LUC|LTT|LTL|LSL|LS|LRD|LKR|LE|LBP|LAK|L\$|L|Kčs|Kč|Kz|Kw|Ksh|Kr|Kn|KZT|KYD|KY\$|KWD|KRW|KRO|KRH|KPW|KMF|KM|KHR|KGS|KES|K|JP¥|JPY|JOD|JMD|JM\$|J\$|Ikr|ITL|ISK|ISJ|IRR|IQD|INR|ILS|ILR|ILP|IE£|IEP|IDR|HUF|HTG|HRK|HRD|HNL|HKD|HK\$|Gs\.|Gs|GYD|GY\$|GWP|GWE|GTQ|GRD|GQE|GNS|GNF|GMD|GIP|GH₵|GHS|GHC|GEL|GEK|GB£|GBP|G\$|G|Ft|Fl£|Fdj|FRF|FR|FK£|FKP|FJD|FJ\$|FIM|FG|FCFP|FCFA|FC|FBu|FB|F\.Rw|F\.G\.|F|E£|Esc\.|Ekr|EUR|ETB|ESP|ESB|ESA|ERN|EG£|EGP|EEK|ECV|ECU|ECS|EC\$|E|Dkr|Db|DZD|DT|DOP|DO\$|DM|DKK|DJF|DEM|DDM|DA|D|Cub\$|CZK|CYP|CVE|CUP|CUC\$|CUC|CU\$|CSK|CSD|CRC|COU|COP|CO\$|CN¥|CNY|CNX|CNH|CLP|CLF|CLE|CL\$|CI\$|CHW|CHF|CHE|CFPF|CFP|CFA|CF|CDF|CAD|CA\$|C\$|BsF|Bs\.|Bs|Br|Bds\$|BZD|BZ\$|BYR|BYN|BYB|BWP|BUK|BTN|BSD|BS\$|BRZ|BRR|BRN|BRL|BRE|BRC|BRB|BR\$|BOV|BOP|BOL|BOB|BND|BN\$|BMD|BM\$|BIF|BHD|BGO|BGN|BGM|BGL|BGK|BGJ|BEL|BEF|BEC|BDT|BD\$|BBD|BB\$|BAN|BAM|BAD|B\/\.|B\$|Ar|Afl\.|Afl|AZN|AZM|AWG|AUD\$|AUD|AU\$|ATS|ARS|ARP|ARM|ARL|ARA|AR\$|AOR|AON|AOK|AOA|ANG|AMD|ALL|ALK|AFN|AFA|AED|ADP|A\$|\*\*\*|\$ US|\$ SG|\$ NZ|\$ HK|\$ AU|\$b|\$UY|\$US|\$U|\$TT|\$SR|\$SG|\$SB|\$RH|\$NZ|\$NA|\$MX|\$MN|\$HK|\$FJ|\$EC|\$CO|\$CL|\$CA|\$C|\$BZ|\$BS|\$BN|\$BM|\$AU|\$AR|\$/g,D=t=>(Array.isArray(t)?t:[t]).map((t=>t===i?"en":t));export function format(...t){return S.format(...t)}export function parse(...t){return S.parse(...t)}let N=class extends n{get defaultFormat(){return this._defaultFormat}set defaultFormat(t){this._defaultFormat=t}get defaultParseFormat(){return this._defaultParseFormat}set defaultParseFormat(t){this._defaultParseFormat=t}get currency(){return this._currency}set currency(t){this._currency=t}get fractionalDigits(){return this._fractionalDigits}set fractionalDigits(t){this._fractionalDigits=t}locale;_defaultFormat;_defaultParseFormat;_currency;_fractionalDigits;format(...t){let i,a;if(1===t.length?(i=t[0],a={}):arguments.length>=2&&(i=t[1],a="string"==typeof t[0]?{format:t[0]}:t[0],s("options",a).isNotMissing()),null==i||isNaN(i))return"";let n=a.format||this.defaultFormat||m.DEFAULT;if(n===m.ROUND_TRIP)return i.toString();const o=n.toLowerCase();if(o===m.CURRENCY||o===m.ACCOUNTING){const t=a.currency||this.currency||"USD";n=o,n+=a.fractionalDigits??this.fractionalDigits??"",n+=t?`$${t}`:""}else o!==m.NUMBER&&o!==m.FIXED_POINT&&o!==m.PERCENT||(n=o,n+=a.fractionalDigits??this.fractionalDigits??"");a.locale=a.locale||this.locale;const c=r(a.locale||e()),l=`${c.join(";")}|${n}`;let u=R.get(l);if(!u){u=[];const t=n.split(";",3);1===t.length?(u[0]=this._createNumberFormatter(c,t[0]),u[1]=u[0],u[2]=u[0]):2===t.length?(u[0]=this._createNumberFormatter(c,t[0]),u[1]=this._createNumberFormatter(c,t[1]),u[2]=u[0]):3===t.length&&(u[0]=this._createNumberFormatter(c,t[0]),u[1]=this._createNumberFormatter(c,t[1]),u[2]=this._createNumberFormatter(c,t[2])),R.set(l,u)}return i>0?u[0](i):i<0?u[1](i):u[2](i)}parse(...t){let i,a;if(1===t.length?(i=t[0],a={}):t.length>=2&&(i=t[1],a="string"==typeof t[0]||Array.isArray(t[0])?{format:t[0]}:t[0]),"number"==typeof i)return i;if("boolean"==typeof i)return i?1:0;if(null==i)return NaN;let n=i.toString().trim();a.locale=a.locale||this.locale;const s=r(a.locale||e()),o=s.join(";");let c=f.get(o);c||(c=this._createNumberParser(s),f.set(o,c));let D,N=1;n?.startsWith("(")&&n.endsWith(")")&&(N=-1,n=n.slice(1,-1));let F=!1;const R="string"==typeof n&&!!n.match(l);R?D=n.replace(l,"").trim():a.format?.includes(m.CURRENCY)&&(D=n.replace(u,"").replace(/\s/g,""),F=D!==n);let S=c(D??n);if(isNaN(S)&&(S=parseFloat(D??n)),isNaN(S))return S;if(R&&(S/=100),S*=N,F)return S;const C=a.format||this.defaultParseFormat,g=[].concat(C||[]),B=!g.length||g.some((t=>{if(t===m.ROUND_TRIP)return S===parseFloat(S.toString());const r=this._createNumberFormatter(s,t,{minimumFractionDigits:0,maximumFractionDigits:20});if(n===r(S))return!0;const e=t.match($);if(e&&""===e[2])for(let r=0;r<=20;r++){const e=this._createNumberFormatter(s,t,{minimumFractionDigits:r,maximumFractionDigits:r});if(n===e(S))return!0}return!1}));return B?S:NaN}_getSerializableProperties(){return{defaultFormat:"initial",defaultParseFormat:"initial",fractionalDigits:"initial",currency:"initial",locale:"initial"}}_createNumberFormatter(t,r,e){const i=e||{},a=D(t);let n=r.match($);if(n){const t=n[1].toLowerCase(),r=Math.min(20,parseInt(n[2]));let e=n[3];t===m.CURRENCY||t===m.ACCOUNTING?e=(e||this.currency||"USD").toUpperCase():(e="",void 0===i.minimumFractionDigits&&(i.minimumFractionDigits=0),void 0===i.maximumFractionDigits&&(i.maximumFractionDigits=Math.max(4,i.minimumFractionDigits))),t===m.PERCENT?i.style="percent":t===m.ACCOUNTING?i.currencySign="accounting":t===m.FIXED_POINT&&(i.useGrouping=!1),isNaN(r)||(i.minimumFractionDigits=r,i.maximumFractionDigits=r);const s=e?new Intl.NumberFormat(a,{style:"currency",currency:e,...i}):new Intl.NumberFormat(a,i);return t=>s.format(t)}n=r.match(/[0#]+|\.|,|%|\\.|(["'])[^\1]+\1|[^0#.,\\'"]+/g);let s=!1,o="",c="",l="",u="";i.minimumFractionDigits=0,i.maximumFractionDigits=0,i.useGrouping=!1;for(let t of n)switch(t[0]){case".":s=!0;break;case",":i.useGrouping=!0;break;case"%":i.style="percent";break;case"0":case"#":s?c+=t:o+=t;break;default:t.startsWith('"')||t.startsWith("'")?t=t.slice(1,-1):t.startsWith("\\")&&(t=t.slice(1)),o||c?u+=t:l+=t}if(o){const t=o.indexOf("0");t>=0&&(i.minimumIntegerDigits=o.length-t)}if(c){const t=c.lastIndexOf("0");i.minimumFractionDigits=t>=0?t+1:0,i.maximumFractionDigits=Math.min(20,c.length)}if(o||c){const t=new Intl.NumberFormat(a,i);return r=>`${l}${t.format(r)}${u}`}return()=>l+u}_createNumberParser(t){const r=D(t),e=new Intl.NumberFormat(r),i=e.formatToParts(12345.6),a=[...new Intl.NumberFormat(r,{useGrouping:!1}).format(9876543210)].reverse(),n=new Map(a.map(((t,r)=>[t,r]))),s=t=>n.get(t).toString();let o=i.find((t=>"group"===t.type)).value;c.some((t=>t===o))&&(o=`${c.join("|")}`);const m=new RegExp(`[${o}]`,"g"),l=new RegExp(`[${i.find((t=>"decimal"===t.type)).value}]`),u=new RegExp(`[${a.join("")}]`,"g"),N=e.format(-1/0),F=e.format(1/0);return t=>{if(t===F)return Number.POSITIVE_INFINITY;if(t===N)return Number.NEGATIVE_INFINITY;const r=t.trim().replace(m,"").replace(l,".").replace(u,s);return r?+r:NaN}}};N=t([a],N);export{N as NumberFormatter};let F=class extends N{get defaultFormat(){return o.numberFormat}set defaultFormat(t){o.numberFormat=t}get currency(){return o.currency}set currency(t){o.currency=t}get fractionalDigits(){return o.fractionalDigits}set fractionalDigits(t){o.fractionalDigits=t}};F=t([a],F);const R=new Map,f=new Map,$=/^([acfnp])(\d*)(?:\$([a-zA-Z]{3}))?$/i,S=new F;export const settings=S;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { FormatSettings } from "./FormatSettings.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options supported by {@link format}.
|
|
4
|
+
*/
|
|
5
|
+
export interface FormatOptions extends FormatSettings {
|
|
6
|
+
/**
|
|
7
|
+
* The string format. See
|
|
8
|
+
* {@link utilities/format/string!StringFormatter.format}.
|
|
9
|
+
*/
|
|
10
|
+
format: string;
|
|
11
|
+
/**
|
|
12
|
+
* The locale to use when formatting numbers and dates. If not specified,
|
|
13
|
+
* the current locale is used (see locale module).
|
|
14
|
+
*/
|
|
15
|
+
locale?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Indicates if a formatted date should be formatted without the time
|
|
18
|
+
* component even if the format suggests to include a time.
|
|
19
|
+
*/
|
|
20
|
+
isDateOnly?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Default settings that affect how strings are formatted.
|
|
24
|
+
*/
|
|
25
|
+
export { settings } from "./FormatSettings.js";
|
|
26
|
+
/**
|
|
27
|
+
* See {@link utilities/format/string!StringFormatter.format}.
|
|
28
|
+
*
|
|
29
|
+
* @param format See {@link utilities/format/string!StringFormatter.format}.
|
|
30
|
+
* @param args See {@link utilities/format/string!StringFormatter.format}.
|
|
31
|
+
*/
|
|
32
|
+
export declare function format(format: string | FormatOptions, ...args: unknown[]): string;
|
|
33
|
+
/**
|
|
34
|
+
* A helper class for formatting strings.
|
|
35
|
+
*/
|
|
36
|
+
export declare class StringFormatter implements FormatSettings {
|
|
37
|
+
/**
|
|
38
|
+
* @inheritDoc
|
|
39
|
+
*/
|
|
40
|
+
get numberFormat(): string;
|
|
41
|
+
set numberFormat(numberFormat: string);
|
|
42
|
+
/**
|
|
43
|
+
* @inheritDoc
|
|
44
|
+
*/
|
|
45
|
+
get dateFormat(): string;
|
|
46
|
+
set dateFormat(dateFormat: string);
|
|
47
|
+
/**
|
|
48
|
+
* @inheritDoc
|
|
49
|
+
*/
|
|
50
|
+
get timeFormat(): string;
|
|
51
|
+
set timeFormat(timeFormat: string);
|
|
52
|
+
/**
|
|
53
|
+
* @inheritDoc
|
|
54
|
+
*/
|
|
55
|
+
get currency(): string;
|
|
56
|
+
set currency(currency: string);
|
|
57
|
+
/**
|
|
58
|
+
* @inheritDoc
|
|
59
|
+
*/
|
|
60
|
+
get fractionalDigits(): number;
|
|
61
|
+
set fractionalDigits(fractionalDigits: number);
|
|
62
|
+
/**
|
|
63
|
+
* @inheritDoc
|
|
64
|
+
*/
|
|
65
|
+
get timeZone(): string;
|
|
66
|
+
/**
|
|
67
|
+
* @inheritDoc
|
|
68
|
+
*/
|
|
69
|
+
set timeZone(value: string);
|
|
70
|
+
private _numberFormat;
|
|
71
|
+
private _dateFormat;
|
|
72
|
+
private _timeFormat;
|
|
73
|
+
private _currency;
|
|
74
|
+
private _fractionalDigits;
|
|
75
|
+
private _timeZone;
|
|
76
|
+
private readonly _numberFormatter;
|
|
77
|
+
private readonly _dateFormatter;
|
|
78
|
+
private readonly _timeFormatter;
|
|
79
|
+
/**
|
|
80
|
+
* Converts the value of objects to strings based on the formats specified
|
|
81
|
+
* and inserts them into another string.
|
|
82
|
+
*
|
|
83
|
+
* @param formatOrOptions The format string that acts as a template. The
|
|
84
|
+
* format string can contain one or more format items, which have this
|
|
85
|
+
* syntax: `{index[:format]}`. The index is the zero-based index of the
|
|
86
|
+
* argument whose string representation is to be included at this position
|
|
87
|
+
* in the string. The optional format is a format string that controls how
|
|
88
|
+
* the argument is converted into a string, if the argument is a Date
|
|
89
|
+
* object or number. To include a literal `{` or `}` character in the
|
|
90
|
+
* output, escape the character by repeating it twice in the format
|
|
91
|
+
* string. This argument can also be a format options object instead.
|
|
92
|
+
* @param args The values to substitute into the format string. Null and
|
|
93
|
+
* undefined values will be converted into empty strings.
|
|
94
|
+
*/
|
|
95
|
+
format(formatOrOptions: string | FormatOptions, ...args: unknown[]): string;
|
|
96
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Time as t}from"../Time.js";import{checkArg as e}from"../checkArg.js";import{settings as r}from"./FormatSettings.js";import{DateFormatter as o,isValidTimeZone as i,ERR_TIME_ZONE_INVALID as a}from"./date.js";import{NumberFormatter as m}from"./number.js";import{TimeFormatter as n}from"./time.js";export{settings}from"./FormatSettings.js";export function format(t,...e){return s.format(t,...e)}export class StringFormatter{get numberFormat(){return this._numberFormat}set numberFormat(t){this._numberFormat=t}get dateFormat(){return this._dateFormat}set dateFormat(t){this._dateFormat=t}get timeFormat(){return this._timeFormat}set timeFormat(t){this._timeFormat=t}get currency(){return this._currency}set currency(t){this._currency=t}get fractionalDigits(){return this._fractionalDigits}set fractionalDigits(t){this._fractionalDigits=t}get timeZone(){return this._timeZone}set timeZone(t){e("timezone",t).satisfies((t=>i(t)),a(t)),this._timeZone=t}_numberFormat;_dateFormat;_timeFormat;_currency;_fractionalDigits;_timeZone;_numberFormatter=new m;_dateFormatter=new o;_timeFormatter=new n;format(r,...o){const i="string"==typeof r?{format:r}:r;e("options",i).isNotMissing();let{format:a}=i;e("format",a).isNotMissing(),a=a.replace(u,g);return a.replace(c,((r,a,m)=>{const n=parseInt(a);let s,c;try{e(`token ${a}`,a).isInRange(0,o.length-1),s=o[n]}catch(t){const e=parseInt(a,10);if(isNaN(e)||e<0)throw t;console.warn(`Error encountered while formatting string: ${t.message}`)}if("number"==typeof s){const t={locale:i.locale,format:m||i.numberFormat||this.numberFormat,currency:i.currency||this.currency,fractionalDigits:i.fractionalDigits??this.fractionalDigits};c=this._numberFormatter.format(t,s)}else if(s instanceof Date){const t={locale:i.locale,format:m||i.dateFormat||this.dateFormat,timeZone:i.timeZone||this.timeZone,isDateOnly:i.isDateOnly};c=this._dateFormatter.format(t,s)}else if(s instanceof t){const t={locale:i.locale,format:m||i.timeFormat||this.timeFormat};c=this._timeFormatter.format(t,s)}else c=null==s?"":String(s);return c})).replace(F,"{").replace("}}","}")}}const s=new class extends StringFormatter{get numberFormat(){return r.numberFormat}set numberFormat(t){r.numberFormat=t}get dateFormat(){return r.dateFormat}set dateFormat(t){r.dateFormat=t}get timeFormat(){return r.timeFormat}set timeFormat(t){r.timeFormat=t}get timeZone(){return r.timeZone}set timeZone(t){r.timeZone=t}get currency(){return r.currency}set currency(t){r.currency=t}get fractionalDigits(){return r.fractionalDigits}set fractionalDigits(t){r.fractionalDigits=t}},c=/\{([-\d]+)(?::([^}]*))?\}/g,u=/{{/g,g="\0MAGIC\0",F=new RegExp(g,"g");
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import type { PropertyDefs } from "../../support/Serializable.js";
|
|
2
|
+
import { SerializableBase } from "../../support/Serializable.js";
|
|
3
|
+
import { Time } from "../Time.js";
|
|
4
|
+
/**
|
|
5
|
+
* The default set of formats used for parsing time values.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_PARSING_FORMATS: string[];
|
|
8
|
+
/**
|
|
9
|
+
* Default settings that affect how times are formatted and parsed.
|
|
10
|
+
*/
|
|
11
|
+
export interface TimeSettings {
|
|
12
|
+
/**
|
|
13
|
+
* The default format for formatting times. See
|
|
14
|
+
* {@link utilities/format/time!TimeFormatter.format}.
|
|
15
|
+
*/
|
|
16
|
+
defaultFormat?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Either a single format, or one of several possible formats that the input
|
|
19
|
+
* is expected to be in. If specified, the input must _exactly_ match. The
|
|
20
|
+
* syntax is the same as for
|
|
21
|
+
* {@link utilities/format/time!TimeFormatter.format}.
|
|
22
|
+
*/
|
|
23
|
+
defaultParseFormat?: string | string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Options supported by {@link format}.
|
|
27
|
+
*/
|
|
28
|
+
export interface FormatOptions {
|
|
29
|
+
/**
|
|
30
|
+
* The locale to use when formatting the time. If not specified, the current
|
|
31
|
+
* locale is used (see locale module).
|
|
32
|
+
*/
|
|
33
|
+
locale?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The time format. See {@link utilities/format/time!TimeFormatter.format}.
|
|
36
|
+
*/
|
|
37
|
+
format?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Options supported by {@link parse}.
|
|
41
|
+
*/
|
|
42
|
+
export interface ParseOptions {
|
|
43
|
+
/**
|
|
44
|
+
* The locale to use when parsing the time. If not specified, the current
|
|
45
|
+
* locale is used (see locale module).
|
|
46
|
+
*/
|
|
47
|
+
locale?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Either a single format, or one of several possible formats that the input
|
|
50
|
+
* is expected to be in. If specified, the input must _exactly_ match. See
|
|
51
|
+
* {@link utilities/format/time!TimeFormatter.format}.
|
|
52
|
+
*/
|
|
53
|
+
format?: string | string[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Formats a time object representing a specific time.
|
|
57
|
+
*
|
|
58
|
+
* @param time The time to format.
|
|
59
|
+
*/
|
|
60
|
+
export declare function format(time: Time): string;
|
|
61
|
+
/**
|
|
62
|
+
* Formats a time object representing a specific time for display.
|
|
63
|
+
*
|
|
64
|
+
* @param format See {@link utilities/format/time!TimeFormatter.format}.
|
|
65
|
+
* @param time The time to format.
|
|
66
|
+
*/
|
|
67
|
+
export declare function format(format: string, time: Time): string;
|
|
68
|
+
/**
|
|
69
|
+
* Formats a time object representing a specific time for display.
|
|
70
|
+
*
|
|
71
|
+
* @param options Specifies the format settings to use.
|
|
72
|
+
* @param time The time to format.
|
|
73
|
+
*/
|
|
74
|
+
export declare function format(options: FormatOptions, time: Time): string;
|
|
75
|
+
/**
|
|
76
|
+
* Parses a value into a Time object.
|
|
77
|
+
*
|
|
78
|
+
* @param input The input to parse.
|
|
79
|
+
* @returns A Time object corresponding to the input. If unable to parse
|
|
80
|
+
* successfully, will return an invalid Time.
|
|
81
|
+
*/
|
|
82
|
+
export declare function parse(input: unknown): Time;
|
|
83
|
+
/**
|
|
84
|
+
* Parses a value into a Time object.
|
|
85
|
+
*
|
|
86
|
+
* @param format See {@link ParseOptions.format}.
|
|
87
|
+
* @param input The input to parse.
|
|
88
|
+
* @returns A Time object corresponding to the input. If unable to parse
|
|
89
|
+
* successfully, will return an invalid Time.
|
|
90
|
+
*/
|
|
91
|
+
export declare function parse(format: string | string[], input: unknown): Time;
|
|
92
|
+
/**
|
|
93
|
+
* Parses a value into a Time object.
|
|
94
|
+
*
|
|
95
|
+
* @param options The options to use for parsing.
|
|
96
|
+
* @param input The input to parse.
|
|
97
|
+
* @returns A Time object corresponding to the input. If unable to parse
|
|
98
|
+
* successfully, will return an invalid Time.
|
|
99
|
+
*/
|
|
100
|
+
export declare function parse(options: ParseOptions, input: unknown): Time;
|
|
101
|
+
/**
|
|
102
|
+
* Converts an Esri-style date format constant for a time (e.g.
|
|
103
|
+
* "short-date-short-time") to a format string that can be used with
|
|
104
|
+
* {@link format} and {@link parse}.
|
|
105
|
+
*
|
|
106
|
+
* @param format The Esri-style format constant to convert.
|
|
107
|
+
*/
|
|
108
|
+
export declare function esriFormatToGeocortexFormat(format: string): string;
|
|
109
|
+
/**
|
|
110
|
+
* Properties that can be passed into the constructor for
|
|
111
|
+
* {@link utilities/format/time!TimeFormatter}.
|
|
112
|
+
*/
|
|
113
|
+
export interface TimeFormatterProperties extends TimeSettings {
|
|
114
|
+
/**
|
|
115
|
+
* The locale to use when formatting & parsing the number. If not specified,
|
|
116
|
+
* the current locale is used (see locale module).
|
|
117
|
+
*/
|
|
118
|
+
locale?: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A helper class for formatting and parsing times.
|
|
122
|
+
*/
|
|
123
|
+
export declare class TimeFormatter extends SerializableBase<TimeFormatterProperties> implements TimeSettings {
|
|
124
|
+
/**
|
|
125
|
+
* @inheritDoc
|
|
126
|
+
*/
|
|
127
|
+
get defaultFormat(): string | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* @inheritDoc
|
|
130
|
+
*/
|
|
131
|
+
set defaultFormat(value: string | undefined);
|
|
132
|
+
/**
|
|
133
|
+
* @inheritDoc
|
|
134
|
+
*/
|
|
135
|
+
defaultParseFormat: string | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* The locale to use when formatting & parsing the time. If not specified,
|
|
138
|
+
* the current locale is used (see locale module).
|
|
139
|
+
*/
|
|
140
|
+
locale: string | undefined;
|
|
141
|
+
private _defaultFormat;
|
|
142
|
+
/**
|
|
143
|
+
* Formats a time for display.
|
|
144
|
+
*
|
|
145
|
+
* @param time The time to format.
|
|
146
|
+
*/
|
|
147
|
+
format(time: Time): string;
|
|
148
|
+
/**
|
|
149
|
+
* Formats a time for display.
|
|
150
|
+
*
|
|
151
|
+
* @param time The time to format.
|
|
152
|
+
* @param format The format for presenting times. One of the
|
|
153
|
+
* {@link utilities/format/formats!TimeFormat} constants, or a custom
|
|
154
|
+
* format string. The format string syntax is similar to
|
|
155
|
+
* {@link https://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx}, with the
|
|
156
|
+
* following exceptions:
|
|
157
|
+
*
|
|
158
|
+
* - ":" is treated as a literal character.
|
|
159
|
+
* - "t" is treated the same as "tt".
|
|
160
|
+
* - "F", "FF", "FFF" etc. will behave the same as "f", "ff", "fff", etc.
|
|
161
|
+
* Additionally, a maximum of 3 digits (milliseconds) is supported.
|
|
162
|
+
* Longer formatters like "fffff" are truncated to 3 digits, rather
|
|
163
|
+
* than padded with zeros.
|
|
164
|
+
* - "K" is not supported at all and will be ignored. If not specified, it
|
|
165
|
+
* will default to TIME_SHORT.
|
|
166
|
+
*/
|
|
167
|
+
format(format: string, time: Time): string;
|
|
168
|
+
/**
|
|
169
|
+
* Formats a time for display.
|
|
170
|
+
*
|
|
171
|
+
* @param time The time to format.
|
|
172
|
+
* @param options Options that control how the time is formatted.
|
|
173
|
+
*/
|
|
174
|
+
format(options: FormatOptions, time: Time): string;
|
|
175
|
+
/**
|
|
176
|
+
* Parses a value into a Time object.
|
|
177
|
+
*
|
|
178
|
+
* @param input The input to parse.
|
|
179
|
+
* @returns A Time object corresponding to the input. If unable to parse
|
|
180
|
+
* successfully, will return an invalid Time.
|
|
181
|
+
*/
|
|
182
|
+
parse(input: unknown): Time;
|
|
183
|
+
/**
|
|
184
|
+
* Parses a value into a Time object.
|
|
185
|
+
*
|
|
186
|
+
* @param input The input to parse.
|
|
187
|
+
* @param format See {@link ParseOptions.format}.
|
|
188
|
+
* @returns A Time object corresponding to the input. If unable to parse
|
|
189
|
+
* successfully, will return an invalid Time.
|
|
190
|
+
*/
|
|
191
|
+
parse(format: string | string[], input: unknown): Time;
|
|
192
|
+
/**
|
|
193
|
+
* Parses a value into a Time object.
|
|
194
|
+
*
|
|
195
|
+
* @param input The input to parse.
|
|
196
|
+
* @param options The options to use for parsing.
|
|
197
|
+
* @returns A Time object corresponding to the input. If unable to parse
|
|
198
|
+
* successfully, will return an invalid Time.
|
|
199
|
+
*/
|
|
200
|
+
parse(options: ParseOptions, input: unknown): Time;
|
|
201
|
+
protected _getSerializableProperties(): PropertyDefs<TimeFormatterProperties>;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Default settings used for formatting and parsing times.
|
|
205
|
+
*/
|
|
206
|
+
export declare const settings: TimeSettings;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__decorate as t}from"tslib";import{DateTime as e}from"luxon";import{get as o,INVARIANT as r}from"../../locale.js";import{serializable as a,SerializableBase as s}from"../../support/Serializable.js";import{Time as n}from"../Time.js";import{settings as i}from"./FormatSettings.js";import{gcxDateTimeFormatToLuxonFormat as m}from"./_utils.js";import{TimeFormat as l}from"./formats.js";export const DEFAULT_PARSING_FORMATS=[l.ISO_8601,l.TIME_SHORT,l.TIME_LONG];export function format(...t){return d.format(...t)}export function parse(...t){return d.parse(...t)}export function esriFormatToGeocortexFormat(t){switch(t){case"short-date-short-time":case"short-date-le-short-time":case"long-month-day-year-short-time":case"day-short-month-year-short-time":case"long-date-short-time":return"t";case"short-date-short-time-24":case"short-date-le-short-time-24":case"long-month-day-year-short-time-24":case"long-date-short-time-24":case"day-short-month-year-short-time-24":return"εσρι H:mm";case"short-date-long-time":case"short-date-le-long-time":case"long-month-day-year-long-time":case"long-date-long-time":case"day-short-month-year-long-time":return"T";case"short-date-long-time-24":case"short-date-le-long-time-24":case"long-month-day-year-long-time-24":case"long-date-long-time-24":case"day-short-month-year-long-time-24":return"εσρι H:mm:ss";default:throw new Error(`Unrecognized time format constant: ${t}`)}}let c=class extends s{get defaultFormat(){return this._defaultFormat}set defaultFormat(t){this._defaultFormat=t}defaultParseFormat;locale;_defaultFormat;format(t,a){let s=a,i={};t instanceof n?s=t:i="string"==typeof t?{format:t}:t;const c=s.toDate();if(isNaN(c.getTime()))return"";const f=i.format||this.defaultFormat||l.DEFAULT,d=m(f);if("ISO-8601"===d)return s.toString();let u=i.locale||this.locale||o();u===r&&(u="en");return e.fromJSDate(c).setLocale(u).toFormat(d)}parse(t,r){let a,s=r;if(null==r?(s=t,a={}):a="string"==typeof t||Array.isArray(t)?{format:t}:t,s instanceof n)return s;if("string"!=typeof s)return new n(new Date(NaN));const i=a.format??this.defaultParseFormat??DEFAULT_PARSING_FORMATS,l=[].concat(i),c={locale:a.locale??this.locale??o()};for(const t of l){const o=m(t);if("ISO-8601"===o){const t=new n(s);if(t.isValid)return t}else{const t=e.fromFormat(s,o,c);if(t.isValid){const e=t.toJSDate();return new n(`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}`)}}}return new n(new Date(NaN))}_getSerializableProperties(){return{defaultFormat:"initial",defaultParseFormat:"initial",locale:"initial"}}};c=t([a],c);export{c as TimeFormatter};let f=class extends c{get defaultFormat(){return i.timeFormat}set defaultFormat(t){i.timeFormat=t}};f=t([a],f);const d=new f;export const settings=d;
|
package/utilities/log.d.ts
CHANGED
|
@@ -22,8 +22,8 @@ export type LoggerFactory = (name: string, logManager: LogManager) => Logger;
|
|
|
22
22
|
export interface LogOptions extends FormatSettings {
|
|
23
23
|
/**
|
|
24
24
|
* A string representing the log message. The format is the same as the
|
|
25
|
-
* syntax for {@link utilities/string!StringFormatter.format},
|
|
26
|
-
* positional arguments.
|
|
25
|
+
* syntax for {@link utilities/format/string!StringFormatter.format},
|
|
26
|
+
* allowing for positional arguments.
|
|
27
27
|
*/
|
|
28
28
|
message?: string;
|
|
29
29
|
/**
|
package/utilities/number.d.ts
CHANGED
|
@@ -1,239 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
import { SerializableBase } from "../support/Serializable.js";
|
|
1
|
+
export type {
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* @deprecated Use {@link utilities/format/number!NumberSettings}.
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* A localized representation of a number with a decimal separator and group
|
|
9
|
-
* separators (e.g. "12,345.67", "-42" for en-US locale).
|
|
10
|
-
*/
|
|
11
|
-
NUMBER = "n",
|
|
12
|
-
/**
|
|
13
|
-
* A localized representation of a number with a decimal separator (e.g.
|
|
14
|
-
* "12345.67", "-42" for en-US locale).
|
|
15
|
-
*/
|
|
16
|
-
FIXED_POINT = "f",
|
|
17
|
-
/**
|
|
18
|
-
* A localized representation of a monetary amount in a specific currency
|
|
19
|
-
* (e.g. "$123.45" for USD, "£123.45" for GBP for en-US locale).
|
|
20
|
-
*/
|
|
21
|
-
CURRENCY = "c",
|
|
22
|
-
/**
|
|
23
|
-
* Same as CURRENCY, except that negative values are displayed in
|
|
24
|
-
* parentheses instead of using a "-" sign.
|
|
25
|
-
*/
|
|
26
|
-
ACCOUNTING = "a",
|
|
27
|
-
/**
|
|
28
|
-
* A localized representation of a percentage (e.g. 0.99 -> "99%" in the
|
|
29
|
-
* en-US locale).
|
|
30
|
-
*/
|
|
31
|
-
PERCENT = "p",
|
|
32
|
-
/**
|
|
33
|
-
* An invariant representation of a number (e.g. "12345.67"). Guarantees
|
|
34
|
-
* that the number can be parsed back into the same number, regardless of
|
|
35
|
-
* locale.
|
|
36
|
-
*/
|
|
37
|
-
ROUND_TRIP = "r",
|
|
38
|
-
/**
|
|
39
|
-
* The default representation for number values (equivalent to FIXED_POINT).
|
|
40
|
-
*/
|
|
41
|
-
DEFAULT = "f"
|
|
42
|
-
}
|
|
5
|
+
NumberSettings,
|
|
43
6
|
/**
|
|
44
|
-
*
|
|
7
|
+
* @deprecated Use {@link utilities/format/number!FormatOptions}.
|
|
45
8
|
*/
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The default format for formatting numbers. See
|
|
49
|
-
* {@link utilities/number!NumberFormatter.format}.
|
|
50
|
-
*/
|
|
51
|
-
defaultFormat?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Either a single format, or one of several possible formats that the input
|
|
54
|
-
* is expected to be in. If specified, the input must _exactly_ match. The
|
|
55
|
-
* syntax is the same as for
|
|
56
|
-
* {@link utilities/number!NumberFormatter.format}.
|
|
57
|
-
*/
|
|
58
|
-
defaultParseFormat?: string | string[];
|
|
59
|
-
/**
|
|
60
|
-
* The 3-letter ISO 4217 currency code (e.g "USD", "CAD"). Required when
|
|
61
|
-
* formatting a number using NumberFormat.CURRENCY or
|
|
62
|
-
* NumberFormat.ACCOUNTING.
|
|
63
|
-
*/
|
|
64
|
-
currency?: string;
|
|
65
|
-
/**
|
|
66
|
-
* The number of digits to show after the decimal point. If unspecified, an
|
|
67
|
-
* appropriate value is determined based on the locale and currency.
|
|
68
|
-
*/
|
|
69
|
-
fractionalDigits?: number;
|
|
70
|
-
}
|
|
9
|
+
FormatOptions,
|
|
71
10
|
/**
|
|
72
|
-
*
|
|
11
|
+
* @deprecated Use {@link utilities/format/number!ParseOptions}.
|
|
73
12
|
*/
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* The locale to use when formatting the number. If not specified, the
|
|
77
|
-
* current locale is used (see locale module).
|
|
78
|
-
*/
|
|
79
|
-
locale?: string;
|
|
80
|
-
/**
|
|
81
|
-
* The number format. See {@link utilities/number!NumberFormatter.format}.
|
|
82
|
-
*/
|
|
83
|
-
format?: string;
|
|
84
|
-
/**
|
|
85
|
-
* See {@link NumberSettings.currency}.
|
|
86
|
-
*/
|
|
87
|
-
currency?: string;
|
|
88
|
-
/**
|
|
89
|
-
* See {@link NumberSettings.fractionalDigits}.
|
|
90
|
-
*/
|
|
91
|
-
fractionalDigits?: number;
|
|
92
|
-
}
|
|
13
|
+
ParseOptions,
|
|
93
14
|
/**
|
|
94
|
-
*
|
|
15
|
+
* @deprecated Use {@link utilities/format/number!NumberFormatterProperties}.
|
|
95
16
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
* The locale to use when parsing the number. If not specified, the current
|
|
99
|
-
* locale is used (see locale module).
|
|
100
|
-
*/
|
|
101
|
-
locale?: string;
|
|
102
|
-
/**
|
|
103
|
-
* Either a single format, or one of several possible formats that the input
|
|
104
|
-
* is expected to be in. If specified, the input must _exactly_ match. See
|
|
105
|
-
* {@link NumberFormatter.format}.
|
|
106
|
-
*/
|
|
107
|
-
format?: string | string[];
|
|
108
|
-
}
|
|
17
|
+
NumberFormatterProperties, } from "./format/number.js";
|
|
18
|
+
export {
|
|
109
19
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* @param value The value to check.
|
|
113
|
-
* @param locale The locale to use when parsing string values.
|
|
20
|
+
* @deprecated Use {@link utilities/format/number!format}.
|
|
114
21
|
*/
|
|
115
|
-
|
|
22
|
+
format,
|
|
116
23
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* @param num The number to format.
|
|
24
|
+
* @deprecated Use {@link utilities/format/number!parse}.
|
|
120
25
|
*/
|
|
121
|
-
|
|
26
|
+
parse,
|
|
122
27
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* @param format See {@link utilities/number!NumberFormatter.format}.
|
|
126
|
-
* @param num The number to format.
|
|
28
|
+
* @deprecated Use {@link utilities/format/number!NumberFormatter}.
|
|
127
29
|
*/
|
|
128
|
-
|
|
30
|
+
NumberFormatter,
|
|
129
31
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* @param options Specifies the format settings to use.
|
|
133
|
-
* @param num The number to format.
|
|
134
|
-
*/
|
|
135
|
-
export declare function format(options: FormatOptions, num: number): string;
|
|
136
|
-
/**
|
|
137
|
-
* Parses a value into a number.
|
|
138
|
-
*
|
|
139
|
-
* @param input The input to parse.
|
|
140
|
-
* @returns A number corresponding to the input, or NaN if the input can't be
|
|
141
|
-
* parsed.
|
|
32
|
+
* @deprecated Use {@link utilities/format/number!settings}.
|
|
142
33
|
*/
|
|
143
|
-
|
|
34
|
+
settings, } from "./format/number.js";
|
|
35
|
+
export {
|
|
144
36
|
/**
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* @param format See {@link ParseOptions.format}.
|
|
148
|
-
* @param input The input to parse.
|
|
149
|
-
* @returns A number corresponding to the input, or NaN if the input can't be
|
|
150
|
-
* parsed.
|
|
37
|
+
* @deprecated Use {@link utilities/format/formats!NumberFormat}.
|
|
151
38
|
*/
|
|
152
|
-
|
|
39
|
+
NumberFormat, } from "./format/formats.js";
|
|
153
40
|
/**
|
|
154
|
-
*
|
|
41
|
+
* Determines whether a value is numeric, i.e. a number or a numeric string.
|
|
155
42
|
*
|
|
156
|
-
* @param
|
|
157
|
-
* @param
|
|
158
|
-
* @returns A number corresponding to the input, or NaN if the input can't be
|
|
159
|
-
* parsed.
|
|
160
|
-
*/
|
|
161
|
-
export declare function parse(options: ParseOptions, input: unknown): number;
|
|
162
|
-
/**
|
|
163
|
-
* Properties that can be passed into the constructor for
|
|
164
|
-
* {@link utilities/number!NumberFormatter}.
|
|
165
|
-
*/
|
|
166
|
-
export interface NumberFormatterProperties extends NumberSettings {
|
|
167
|
-
/**
|
|
168
|
-
* The locale to use when formatting & parsing the number. If not specified,
|
|
169
|
-
* the current locale is used (see locale module).
|
|
170
|
-
*/
|
|
171
|
-
locale?: string;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* A helper class for formatting and parsing numbers.
|
|
175
|
-
*/
|
|
176
|
-
export declare class NumberFormatter extends SerializableBase<NumberFormatterProperties> implements NumberSettings {
|
|
177
|
-
/**
|
|
178
|
-
* @inheritDoc
|
|
179
|
-
*/
|
|
180
|
-
get defaultFormat(): string;
|
|
181
|
-
set defaultFormat(defaultFormat: string);
|
|
182
|
-
/**
|
|
183
|
-
* @inheritDoc
|
|
184
|
-
*/
|
|
185
|
-
get defaultParseFormat(): string;
|
|
186
|
-
set defaultParseFormat(defaultParseFormat: string);
|
|
187
|
-
/**
|
|
188
|
-
* @inheritDoc
|
|
189
|
-
*/
|
|
190
|
-
get currency(): string;
|
|
191
|
-
set currency(currency: string);
|
|
192
|
-
/**
|
|
193
|
-
* @inheritDoc
|
|
194
|
-
*/
|
|
195
|
-
get fractionalDigits(): number;
|
|
196
|
-
set fractionalDigits(fractionalDigits: number);
|
|
197
|
-
/**
|
|
198
|
-
* The locale to use when formatting & parsing the number. If not specified,
|
|
199
|
-
* the current locale is used (see locale module).
|
|
200
|
-
*/
|
|
201
|
-
locale: string;
|
|
202
|
-
private _defaultFormat;
|
|
203
|
-
private _defaultParseFormat;
|
|
204
|
-
private _currency;
|
|
205
|
-
private _fractionalDigits;
|
|
206
|
-
/**
|
|
207
|
-
* See {@link format}.
|
|
208
|
-
*/
|
|
209
|
-
format(format: string, num: number): string;
|
|
210
|
-
format(options: FormatOptions, num: number): string;
|
|
211
|
-
format(num: number): string;
|
|
212
|
-
/**
|
|
213
|
-
* See {@link parse}.
|
|
214
|
-
*/
|
|
215
|
-
parse(input: unknown): number;
|
|
216
|
-
parse(format: string | string[], input: unknown): number;
|
|
217
|
-
parse(options: ParseOptions, input: unknown): number;
|
|
218
|
-
protected _getSerializableProperties(): PropertyDefs<NumberFormatterProperties>;
|
|
219
|
-
/**
|
|
220
|
-
* Converts a format string accepted by formatNumber() to formatter
|
|
221
|
-
* function.
|
|
222
|
-
*
|
|
223
|
-
* @param inputLocales The locale.
|
|
224
|
-
* @param format The format to use.
|
|
225
|
-
* @param defaultOptions Options that control how values are formatted.
|
|
226
|
-
*/
|
|
227
|
-
private _createNumberFormatter;
|
|
228
|
-
/**
|
|
229
|
-
* Create a numeric parser function for a set of locales.
|
|
230
|
-
*
|
|
231
|
-
* @param inputLocales An ordered array of locales to be used for parsing
|
|
232
|
-
* sorted in order of precedence.
|
|
233
|
-
*/
|
|
234
|
-
private _createNumberParser;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Default settings used for formatting and parsing numbers.
|
|
43
|
+
* @param value The value to check.
|
|
44
|
+
* @param locale The locale to use when parsing string values.
|
|
238
45
|
*/
|
|
239
|
-
export declare
|
|
46
|
+
export declare function isNumeric(value: unknown, locale?: string): boolean;
|
package/utilities/number.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isNumericInvariant as r}from"./_number.js";import{parse as m}from"./format/number.js";export{format,parse,NumberFormatter,settings}from"./format/number.js";export{NumberFormat}from"./format/formats.js";export function isNumeric(o,t="inv"){return t&&"inv"!==t&&"string"==typeof o?!isNaN(m({locale:t},o)):r(o)}
|