@stryke/string-format 0.12.12 → 0.12.20
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/CHANGELOG.md +485 -0
- package/README.md +19 -9
- package/dist/acronyms-Clf_sxuQ.d.mts +17 -0
- package/dist/acronyms-Clf_sxuQ.d.mts.map +1 -0
- package/dist/acronyms-CqHURYjd.mjs +2 -0
- package/dist/acronyms-CqHURYjd.mjs.map +1 -0
- package/dist/acronyms-D4QIJv0a.d.cts +17 -0
- package/dist/acronyms-D4QIJv0a.d.cts.map +1 -0
- package/dist/acronyms-DiyHB1FK.cjs +1 -0
- package/dist/acronyms.cjs +1 -923
- package/dist/acronyms.d.cts +2 -0
- package/dist/acronyms.d.mts +2 -0
- package/dist/acronyms.mjs +1 -1
- package/dist/articles-Cla7DH2n.d.mts +5 -0
- package/dist/articles-Cla7DH2n.d.mts.map +1 -0
- package/dist/articles-D9xvmhoM.cjs +1 -0
- package/dist/articles-DzjpMs-D.d.cts +5 -0
- package/dist/articles-DzjpMs-D.d.cts.map +1 -0
- package/dist/articles-Dzsbtfwj.mjs +2 -0
- package/dist/articles-Dzsbtfwj.mjs.map +1 -0
- package/dist/articles.cjs +1 -7
- package/dist/articles.d.cts +2 -0
- package/dist/articles.d.mts +2 -0
- package/dist/articles.mjs +1 -1
- package/dist/base-BHbehXQX.mjs +2 -0
- package/dist/base-BHbehXQX.mjs.map +1 -0
- package/dist/base-DdjslzIj.cjs +1 -0
- package/dist/{camel-case.d.ts → camel-case-BjbgGrxH.d.mts} +6 -2
- package/dist/camel-case-BjbgGrxH.d.mts.map +1 -0
- package/dist/camel-case-C05avVyv.cjs +1 -0
- package/dist/camel-case-CZhC2BRe.d.cts +24 -0
- package/dist/camel-case-CZhC2BRe.d.cts.map +1 -0
- package/dist/camel-case-GuOpCLmz.mjs +2 -0
- package/dist/camel-case-GuOpCLmz.mjs.map +1 -0
- package/dist/camel-case.cjs +1 -15
- package/dist/camel-case.d.cts +2 -0
- package/dist/camel-case.d.mts +2 -0
- package/dist/camel-case.mjs +1 -1
- package/dist/combine-CAxhmyey.mjs +2 -0
- package/dist/combine-CAxhmyey.mjs.map +1 -0
- package/dist/combine-DZZlBlm_.d.cts +12 -0
- package/dist/combine-DZZlBlm_.d.cts.map +1 -0
- package/dist/combine-PAQYt88F.cjs +1 -0
- package/dist/combine-g1cpXeuj.d.mts +12 -0
- package/dist/combine-g1cpXeuj.d.mts.map +1 -0
- package/dist/combine.cjs +1 -9
- package/dist/combine.d.cts +2 -0
- package/dist/combine.d.mts +2 -0
- package/dist/combine.mjs +1 -1
- package/dist/conjunctions-B7prVj02.d.mts +5 -0
- package/dist/conjunctions-B7prVj02.d.mts.map +1 -0
- package/dist/conjunctions-CWyOkdmq.mjs +2 -0
- package/dist/conjunctions-CWyOkdmq.mjs.map +1 -0
- package/dist/conjunctions-CaM47PDl.cjs +1 -0
- package/dist/conjunctions-Chb943kG.d.cts +5 -0
- package/dist/conjunctions-Chb943kG.d.cts.map +1 -0
- package/dist/conjunctions.cjs +1 -7
- package/dist/conjunctions.d.cts +2 -0
- package/dist/conjunctions.d.mts +2 -0
- package/dist/conjunctions.mjs +1 -1
- package/dist/constant-case-B0oTEBjC.cjs +1 -0
- package/dist/constant-case-Cn0OS_D5.mjs +2 -0
- package/dist/constant-case-Cn0OS_D5.mjs.map +1 -0
- package/dist/{constant-case.d.ts → constant-case-m6XLIpEZ.d.mts} +6 -2
- package/dist/constant-case-m6XLIpEZ.d.mts.map +1 -0
- package/dist/constant-case-w4mBqXc4.d.cts +24 -0
- package/dist/constant-case-w4mBqXc4.d.cts.map +1 -0
- package/dist/constant-case.cjs +1 -15
- package/dist/constant-case.d.cts +2 -0
- package/dist/constant-case.d.mts +2 -0
- package/dist/constant-case.mjs +1 -1
- package/dist/{deburr.d.ts → deburr-Bc41oTWI.d.mts} +5 -1
- package/dist/deburr-Bc41oTWI.d.mts.map +1 -0
- package/dist/deburr-Brmq0CIE.d.cts +24 -0
- package/dist/deburr-Brmq0CIE.d.cts.map +1 -0
- package/dist/deburr-Ct9BIF1O.mjs +2 -0
- package/dist/deburr-Ct9BIF1O.mjs.map +1 -0
- package/dist/deburr-ulWvJuGq.cjs +1 -0
- package/dist/deburr.cjs +1 -10
- package/dist/deburr.d.cts +2 -0
- package/dist/deburr.d.mts +2 -0
- package/dist/deburr.mjs +1 -1
- package/dist/decamelize-CO4-wIwF.cjs +1 -0
- package/dist/{decamelize.d.ts → decamelize-CXxqH9_o.d.mts} +5 -1
- package/dist/decamelize-CXxqH9_o.d.mts.map +1 -0
- package/dist/decamelize-CuI8547m.mjs +2 -0
- package/dist/decamelize-CuI8547m.mjs.map +1 -0
- package/dist/decamelize-esVsRIRg.d.cts +11 -0
- package/dist/decamelize-esVsRIRg.d.cts.map +1 -0
- package/dist/decamelize.cjs +1 -9
- package/dist/decamelize.d.cts +2 -0
- package/dist/decamelize.d.mts +2 -0
- package/dist/decamelize.mjs +1 -1
- package/dist/{escape.d.ts → escape-C1LTGJQ1.d.cts} +5 -1
- package/dist/escape-C1LTGJQ1.d.cts.map +1 -0
- package/dist/escape-C44shywT.d.mts +21 -0
- package/dist/escape-C44shywT.d.mts.map +1 -0
- package/dist/escape-CRoXgV4v.cjs +1 -0
- package/dist/escape-CydJ1P9x.mjs +2 -0
- package/dist/escape-CydJ1P9x.mjs.map +1 -0
- package/dist/escape.cjs +1 -16
- package/dist/escape.d.cts +2 -0
- package/dist/escape.d.mts +2 -0
- package/dist/escape.mjs +1 -1
- package/dist/format-special-cases-CuctZ76T.cjs +1 -0
- package/dist/format-special-cases-DLTiwMAS.d.mts +23 -0
- package/dist/format-special-cases-DLTiwMAS.d.mts.map +1 -0
- package/dist/format-special-cases-Db69zjlV.d.cts +23 -0
- package/dist/format-special-cases-Db69zjlV.d.cts.map +1 -0
- package/dist/format-special-cases-F9O32YcB.mjs +2 -0
- package/dist/format-special-cases-F9O32YcB.mjs.map +1 -0
- package/dist/format-special-cases.cjs +1 -17
- package/dist/format-special-cases.d.cts +2 -0
- package/dist/format-special-cases.d.mts +2 -0
- package/dist/format-special-cases.mjs +1 -1
- package/dist/{get-words.d.ts → get-words-Cdgu0ngS.d.cts} +16 -12
- package/dist/get-words-Cdgu0ngS.d.cts.map +1 -0
- package/dist/get-words-De8YIU0J.d.mts +47 -0
- package/dist/get-words-De8YIU0J.d.mts.map +1 -0
- package/dist/get-words-IF97Rpfr.cjs +1 -0
- package/dist/get-words-vlruPM_Q.mjs +2 -0
- package/dist/get-words-vlruPM_Q.mjs.map +1 -0
- package/dist/get-words.cjs +1 -13
- package/dist/get-words.d.cts +2 -0
- package/dist/get-words.d.mts +2 -0
- package/dist/get-words.mjs +1 -1
- package/dist/index.cjs +1 -302
- package/dist/index.d.cts +28 -0
- package/dist/index.d.mts +28 -0
- package/dist/index.mjs +1 -1
- package/dist/kebab-case-CT-vTX1k.mjs +2 -0
- package/dist/kebab-case-CT-vTX1k.mjs.map +1 -0
- package/dist/kebab-case-P86ZRHrn.cjs +1 -0
- package/dist/{kebab-case.d.ts → kebab-case-j61N8v5l.d.cts} +6 -2
- package/dist/kebab-case-j61N8v5l.d.cts.map +1 -0
- package/dist/kebab-case-pl--iN9P.d.mts +24 -0
- package/dist/kebab-case-pl--iN9P.d.mts.map +1 -0
- package/dist/kebab-case.cjs +1 -16
- package/dist/kebab-case.d.cts +2 -0
- package/dist/kebab-case.d.mts +2 -0
- package/dist/kebab-case.mjs +1 -1
- package/dist/lower-case-first-BSnwPTwZ.d.cts +14 -0
- package/dist/lower-case-first-BSnwPTwZ.d.cts.map +1 -0
- package/dist/lower-case-first-CES45S2D.cjs +1 -0
- package/dist/lower-case-first-CVRU3SQT.mjs +2 -0
- package/dist/lower-case-first-CVRU3SQT.mjs.map +1 -0
- package/dist/lower-case-first-_dvT-gH7.d.mts +14 -0
- package/dist/lower-case-first-_dvT-gH7.d.mts.map +1 -0
- package/dist/lower-case-first.cjs +1 -9
- package/dist/lower-case-first.d.cts +2 -0
- package/dist/lower-case-first.d.mts +2 -0
- package/dist/lower-case-first.mjs +1 -1
- package/dist/{normalize-email.d.ts → normalize-email-BGivsxZI.d.cts} +5 -1
- package/dist/normalize-email-BGivsxZI.d.cts.map +1 -0
- package/dist/normalize-email-DRezSgOV.cjs +1 -0
- package/dist/normalize-email-bfhnC3KA.d.mts +20 -0
- package/dist/normalize-email-bfhnC3KA.d.mts.map +1 -0
- package/dist/normalize-email-us4o_m-8.mjs +2 -0
- package/dist/normalize-email-us4o_m-8.mjs.map +1 -0
- package/dist/normalize-email.cjs +1 -19
- package/dist/normalize-email.d.cts +2 -0
- package/dist/normalize-email.d.mts +2 -0
- package/dist/normalize-email.mjs +1 -1
- package/dist/package-BSidq8g2.mjs +2 -0
- package/dist/package-BSidq8g2.mjs.map +1 -0
- package/dist/package-Cw2gkIBD.cjs +1 -0
- package/dist/{package.d.ts → package-dwE_olpo.d.mts} +8 -4
- package/dist/package-dwE_olpo.d.mts.map +1 -0
- package/dist/package-o2QJauB-.d.cts +112 -0
- package/dist/package-o2QJauB-.d.cts.map +1 -0
- package/dist/package.cjs +1 -21
- package/dist/package.d.cts +2 -0
- package/dist/package.d.mts +2 -0
- package/dist/package.mjs +1 -1
- package/dist/pad-7O_mbugy.cjs +1 -0
- package/dist/pad-B___Grg_.mjs +2 -0
- package/dist/pad-B___Grg_.mjs.map +1 -0
- package/dist/{pad.d.ts → pad-C-Y_3U-y.d.cts} +5 -1
- package/dist/pad-C-Y_3U-y.d.cts.map +1 -0
- package/dist/pad-mujSKqwW.d.mts +22 -0
- package/dist/pad-mujSKqwW.d.mts.map +1 -0
- package/dist/pad.cjs +1 -9
- package/dist/pad.d.cts +2 -0
- package/dist/pad.d.mts +2 -0
- package/dist/pad.mjs +1 -1
- package/dist/pascal-case-BNtNlP7E.mjs +2 -0
- package/dist/pascal-case-BNtNlP7E.mjs.map +1 -0
- package/dist/pascal-case-BQIXhOgM.cjs +1 -0
- package/dist/{pascal-case.d.ts → pascal-case-DpwdMyIR.d.mts} +6 -2
- package/dist/pascal-case-DpwdMyIR.d.mts.map +1 -0
- package/dist/pascal-case-KPXemzHF.d.cts +24 -0
- package/dist/pascal-case-KPXemzHF.d.cts.map +1 -0
- package/dist/pascal-case.cjs +1 -15
- package/dist/pascal-case.d.cts +2 -0
- package/dist/pascal-case.d.mts +2 -0
- package/dist/pascal-case.mjs +1 -1
- package/dist/period-split-BN6zXi_S.cjs +1 -0
- package/dist/{period-split.d.ts → period-split-C2v7R4SQ.d.cts} +6 -2
- package/dist/period-split-C2v7R4SQ.d.cts.map +1 -0
- package/dist/period-split-CBVGYrUw.d.mts +24 -0
- package/dist/period-split-CBVGYrUw.d.mts.map +1 -0
- package/dist/period-split-PMoklYb7.mjs +2 -0
- package/dist/period-split-PMoklYb7.mjs.map +1 -0
- package/dist/period-split.cjs +1 -17
- package/dist/period-split.d.cts +2 -0
- package/dist/period-split.d.mts +2 -0
- package/dist/period-split.mjs +1 -1
- package/dist/prepositions-BOeFQ28J.mjs +2 -0
- package/dist/prepositions-BOeFQ28J.mjs.map +1 -0
- package/dist/prepositions-Bp1VMgpn.cjs +1 -0
- package/dist/prepositions-By1zoaRG.d.cts +5 -0
- package/dist/prepositions-By1zoaRG.d.cts.map +1 -0
- package/dist/prepositions-DHokBFOW.d.mts +5 -0
- package/dist/prepositions-DHokBFOW.d.mts.map +1 -0
- package/dist/prepositions.cjs +1 -7
- package/dist/prepositions.d.cts +2 -0
- package/dist/prepositions.d.mts +2 -0
- package/dist/prepositions.mjs +1 -1
- package/dist/pretty-bytes-Dam2n54B.d.mts +152 -0
- package/dist/pretty-bytes-Dam2n54B.d.mts.map +1 -0
- package/dist/pretty-bytes-DmvsumO5.mjs +2 -0
- package/dist/pretty-bytes-DmvsumO5.mjs.map +1 -0
- package/dist/pretty-bytes-Dv8t5D6N.d.cts +152 -0
- package/dist/pretty-bytes-Dv8t5D6N.d.cts.map +1 -0
- package/dist/pretty-bytes-aHFwwFbw.cjs +1 -0
- package/dist/pretty-bytes.cjs +1 -48
- package/dist/pretty-bytes.d.cts +2 -0
- package/dist/pretty-bytes.d.mts +2 -0
- package/dist/pretty-bytes.mjs +1 -1
- package/dist/{snake-case.d.ts → snake-case-C5v7aTGP.d.cts} +8 -4
- package/dist/snake-case-C5v7aTGP.d.cts.map +1 -0
- package/dist/snake-case-CKf8oDuS.d.mts +28 -0
- package/dist/snake-case-CKf8oDuS.d.mts.map +1 -0
- package/dist/snake-case.cjs +1 -22
- package/dist/snake-case.d.cts +2 -0
- package/dist/snake-case.d.mts +2 -0
- package/dist/snake-case.mjs +1 -1
- package/dist/special-cases-Ab3-SD5v.d.cts +5 -0
- package/dist/special-cases-Ab3-SD5v.d.cts.map +1 -0
- package/dist/special-cases-CfBSDTk8.cjs +1 -0
- package/dist/special-cases-D7iFXvkR.d.mts +5 -0
- package/dist/special-cases-D7iFXvkR.d.mts.map +1 -0
- package/dist/special-cases-gNNOSEbK.mjs +2 -0
- package/dist/special-cases-gNNOSEbK.mjs.map +1 -0
- package/dist/special-cases.cjs +1 -7
- package/dist/special-cases.d.cts +2 -0
- package/dist/special-cases.d.mts +2 -0
- package/dist/special-cases.mjs +1 -1
- package/dist/{start-case.d.ts → start-case-B9JLArn_.d.mts} +6 -2
- package/dist/start-case-B9JLArn_.d.mts.map +1 -0
- package/dist/start-case-CbdCqiBN.mjs +2 -0
- package/dist/start-case-CbdCqiBN.mjs.map +1 -0
- package/dist/start-case-ChU_5Pyw.cjs +1 -0
- package/dist/start-case-CsYY3Ed4.d.cts +32 -0
- package/dist/start-case-CsYY3Ed4.d.cts.map +1 -0
- package/dist/start-case.cjs +1 -18
- package/dist/start-case.d.cts +2 -0
- package/dist/start-case.d.mts +2 -0
- package/dist/start-case.mjs +1 -1
- package/dist/strip-indents-CPW83oCs.cjs +3 -0
- package/dist/strip-indents-D2-u4Zmx.mjs +4 -0
- package/dist/strip-indents-D2-u4Zmx.mjs.map +1 -0
- package/dist/{strip-indents.d.ts → strip-indents-DBLDecNL.d.cts} +5 -1
- package/dist/strip-indents-DBLDecNL.d.cts.map +1 -0
- package/dist/strip-indents-Dtn3rr-P.d.mts +21 -0
- package/dist/strip-indents-Dtn3rr-P.d.mts.map +1 -0
- package/dist/strip-indents.cjs +1 -11
- package/dist/strip-indents.d.cts +2 -0
- package/dist/strip-indents.d.mts +2 -0
- package/dist/strip-indents.mjs +1 -3
- package/dist/title-case-B_fyCnko.cjs +1 -0
- package/dist/title-case-Cx3FA_Rw.d.mts +15 -0
- package/dist/title-case-Cx3FA_Rw.d.mts.map +1 -0
- package/dist/title-case-DHhN2pBE.mjs +2 -0
- package/dist/title-case-DHhN2pBE.mjs.map +1 -0
- package/dist/title-case-mvtRcmDU.d.cts +15 -0
- package/dist/title-case-mvtRcmDU.d.cts.map +1 -0
- package/dist/title-case.cjs +1 -13
- package/dist/title-case.d.cts +2 -0
- package/dist/title-case.d.mts +2 -0
- package/dist/title-case.mjs +1 -1
- package/dist/{unescape.d.ts → unescape-5MrwINOf.d.cts} +5 -1
- package/dist/unescape-5MrwINOf.d.cts.map +1 -0
- package/dist/unescape-9cS7rNT5.d.mts +20 -0
- package/dist/unescape-9cS7rNT5.d.mts.map +1 -0
- package/dist/unescape-CKwnSwBD.mjs +2 -0
- package/dist/unescape-CKwnSwBD.mjs.map +1 -0
- package/dist/unescape-Ck5lwccz.cjs +1 -0
- package/dist/unescape.cjs +1 -16
- package/dist/unescape.d.cts +2 -0
- package/dist/unescape.d.mts +2 -0
- package/dist/unescape.mjs +1 -1
- package/dist/upper-case-first-Bwfq-lAe.d.mts +14 -0
- package/dist/upper-case-first-Bwfq-lAe.d.mts.map +1 -0
- package/dist/upper-case-first-Ca89zvpr.mjs +2 -0
- package/dist/upper-case-first-Ca89zvpr.mjs.map +1 -0
- package/dist/upper-case-first-IJMSoKjS.cjs +1 -0
- package/dist/upper-case-first-uHFwRCJ8.d.cts +14 -0
- package/dist/upper-case-first-uHFwRCJ8.d.cts.map +1 -0
- package/dist/upper-case-first.cjs +1 -9
- package/dist/upper-case-first.d.cts +2 -0
- package/dist/upper-case-first.d.mts +2 -0
- package/dist/upper-case-first.mjs +1 -1
- package/package.json +87 -409
- package/dist/acronyms.d.ts +0 -13
- package/dist/articles.d.ts +0 -1
- package/dist/combine.d.ts +0 -8
- package/dist/conjunctions.d.ts +0 -1
- package/dist/format-special-cases.d.ts +0 -19
- package/dist/index.d.ts +0 -35
- package/dist/lower-case-first.d.ts +0 -10
- package/dist/prepositions.d.ts +0 -1
- package/dist/pretty-bytes.d.ts +0 -148
- package/dist/special-cases.d.ts +0 -1
- package/dist/title-case.d.ts +0 -9
- package/dist/upper-case-first.d.ts +0 -10
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
//#region src/pretty-bytes.d.ts
|
|
2
|
+
interface Options {
|
|
3
|
+
/**
|
|
4
|
+
* Include plus sign for positive numbers. If the difference is exactly zero a space character will be prepended instead for better alignment.
|
|
5
|
+
*
|
|
6
|
+
* @defaultValue false
|
|
7
|
+
*/
|
|
8
|
+
readonly signed?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* - If `false`: Output won't be localized.
|
|
11
|
+
* - If `true`: Localize the output using the system/browser locale.
|
|
12
|
+
* - If `string`: Expects a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
|
|
13
|
+
* - If `string[]`: Expects a list of [BCP 47 language tags](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
|
|
14
|
+
*
|
|
15
|
+
* @defaultValue false
|
|
16
|
+
*/
|
|
17
|
+
readonly locale?: boolean | string | readonly string[];
|
|
18
|
+
/**
|
|
19
|
+
* Format the number as [bits](https://en.wikipedia.org/wiki/Bit) instead of [bytes](https://en.wikipedia.org/wiki/Byte). This can be useful when, for example, referring to [bit rate](https://en.wikipedia.org/wiki/Bit_rate).
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue false
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
26
|
+
*
|
|
27
|
+
* prettyBytes(1337, {bits: true});
|
|
28
|
+
* //=> '1.34 kbit'
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
readonly bits?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Format the number using the [Binary Prefix](https://en.wikipedia.org/wiki/Binary_prefix) instead of the [SI Prefix](https://en.wikipedia.org/wiki/SI_prefix). This can be useful for presenting memory amounts. However, this should not be used for presenting file sizes.
|
|
34
|
+
*
|
|
35
|
+
* @defaultValue false
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
40
|
+
*
|
|
41
|
+
* prettyBytes(1000, {binary: true});
|
|
42
|
+
* //=> '1000 bit'
|
|
43
|
+
*
|
|
44
|
+
* prettyBytes(1024, {binary: true});
|
|
45
|
+
* //=> '1 kiB'
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
readonly binary?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The minimum number of fraction digits to display.
|
|
51
|
+
*
|
|
52
|
+
* If neither `minimumFractionDigits` or `maximumFractionDigits` are set, the default behavior is to round to 3 significant digits.
|
|
53
|
+
*
|
|
54
|
+
* @defaultValue undefined
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
59
|
+
*
|
|
60
|
+
* // Show the number with at least 3 fractional digits
|
|
61
|
+
* prettyBytes(1900, {minimumFractionDigits: 3});
|
|
62
|
+
* //=> '1.900 kB'
|
|
63
|
+
*
|
|
64
|
+
* prettyBytes(1900);
|
|
65
|
+
* //=> '1.9 kB'
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
readonly minimumFractionDigits?: number;
|
|
69
|
+
/**
|
|
70
|
+
* The maximum number of fraction digits to display.
|
|
71
|
+
*
|
|
72
|
+
* If neither `minimumFractionDigits` or `maximumFractionDigits` are set, the default behavior is to round to 3 significant digits.
|
|
73
|
+
*
|
|
74
|
+
* @defaultValue undefined
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
79
|
+
*
|
|
80
|
+
* // Show the number with at most 1 fractional digit
|
|
81
|
+
* prettyBytes(1920, {maximumFractionDigits: 1});
|
|
82
|
+
* //=> '1.9 kB'
|
|
83
|
+
*
|
|
84
|
+
* prettyBytes(1920);
|
|
85
|
+
* //=> '1.92 kB'
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
readonly maximumFractionDigits?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Put a space between the number and unit.
|
|
91
|
+
*
|
|
92
|
+
* @defaultValue true
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
97
|
+
*
|
|
98
|
+
* prettyBytes(1920, {space: false});
|
|
99
|
+
* //=> '1.9kB'
|
|
100
|
+
*
|
|
101
|
+
* prettyBytes(1920);
|
|
102
|
+
* //=> '1.92 kB'
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
readonly space?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Formats the given number using `Number#toLocaleString`.
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* - If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
|
112
|
+
* - If locale is true, the system default locale is used for translation.
|
|
113
|
+
* - If no value for locale is specified, the number is returned unmodified.
|
|
114
|
+
*
|
|
115
|
+
* @param number - The number to format.
|
|
116
|
+
* @param locale - The locale to use for formatting the number.
|
|
117
|
+
* @param options - The options to use for formatting the number.
|
|
118
|
+
* @returns The formatted number.
|
|
119
|
+
*/
|
|
120
|
+
declare const toLocaleString: (number?: number | string, locale?: string | readonly string[] | boolean, options?: Options) => string;
|
|
121
|
+
/**
|
|
122
|
+
* Convert bytes to a human readable string: `1337` → `1.34 kB`.
|
|
123
|
+
*
|
|
124
|
+
* @param number - The number to format.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
129
|
+
*
|
|
130
|
+
* prettyBytes(1337);
|
|
131
|
+
* //=> '1.34 kB'
|
|
132
|
+
*
|
|
133
|
+
* prettyBytes(100);
|
|
134
|
+
* //=> '100 B'
|
|
135
|
+
*
|
|
136
|
+
* // Display file size differences
|
|
137
|
+
* prettyBytes(42, {signed: true});
|
|
138
|
+
* //=> '+42 B'
|
|
139
|
+
*
|
|
140
|
+
* // Localized output using German locale
|
|
141
|
+
* prettyBytes(1337, {locale: 'de'});
|
|
142
|
+
* //=> '1,34 kB'
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @param number - The number to format.
|
|
146
|
+
* @param options - The options to use.
|
|
147
|
+
* @returns The formatted string.
|
|
148
|
+
*/
|
|
149
|
+
declare function prettyBytes(number: number, options?: Options): string;
|
|
150
|
+
//#endregion
|
|
151
|
+
export { prettyBytes as n, toLocaleString as r, Options as t };
|
|
152
|
+
//# sourceMappingURL=pretty-bytes-Dam2n54B.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pretty-bytes-Dam2n54B.d.mts","names":[],"sources":["../src/pretty-bytes.ts"],"sourcesContent":[],"mappings":";UAkBiB,OAAA;EAAA;AAgKjB;AAiDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAjDa,oGAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8CK,WAAA,2BAAsC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=[`B`,`kB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],t=[`B`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],n=[`b`,`kbit`,`Mbit`,`Gbit`,`Tbit`,`Pbit`,`Ebit`,`Zbit`,`Ybit`],r=[`b`,`kibit`,`Mibit`,`Gibit`,`Tibit`,`Pibit`,`Eibit`,`Zibit`,`Yibit`],i=(e,t,n={})=>{let r=e,i=t;return typeof i==`string`?(i||=process.env.STORM_LOCALE||`en-US`,Array.isArray(i)&&(r=e?.toLocaleString(i,n))):(i===!0||n!==void 0)&&(r=e?.toLocaleString(void 0,n)),String(r)};function a(a,o){let s=a;if(!Number.isFinite(s))throw TypeError(`Expected a finite number, got ${typeof s}: ${s}`);let c={bits:!1,binary:!1,space:!0,...o},l=c.bits?c.binary?r:n:c.binary?t:e,u=c.space?` `:``;if(c.signed&&s===0)return` 0${u}${l[0]}`;let d=s<0,f=d?`-`:c.signed?`+`:``;d&&(s=-s);let p;if(c.minimumFractionDigits!==void 0&&(p={minimumFractionDigits:c.minimumFractionDigits}),c.maximumFractionDigits!==void 0&&(p={maximumFractionDigits:c.maximumFractionDigits,...p}),s<1)return f+i(s,c.locale,p)+u+l[0];let m=Math.min(Math.floor(c.binary?Math.log(s)/Math.log(1024):Math.log10(s)/3),l.length-1);s/=(c.binary?1024:1e3)**m,p||(s=s.toPrecision(3));let h=i(Number(s),c.locale,p),g=l[m];return f+h+u+g}export{i as n,a as t};
|
|
2
|
+
//# sourceMappingURL=pretty-bytes-DmvsumO5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pretty-bytes-DmvsumO5.mjs","names":["_number: string | number"],"sources":["../src/pretty-bytes.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport interface Options {\n /**\n * Include plus sign for positive numbers. If the difference is exactly zero a space character will be prepended instead for better alignment.\n *\n * @defaultValue false\n */\n readonly signed?: boolean;\n\n /**\n * - If `false`: Output won't be localized.\n * - If `true`: Localize the output using the system/browser locale.\n * - If `string`: Expects a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)\n * - If `string[]`: Expects a list of [BCP 47 language tags](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)\n *\n * @defaultValue false\n */\n readonly locale?: boolean | string | readonly string[];\n\n /**\n * Format the number as [bits](https://en.wikipedia.org/wiki/Bit) instead of [bytes](https://en.wikipedia.org/wiki/Byte). This can be useful when, for example, referring to [bit rate](https://en.wikipedia.org/wiki/Bit_rate).\n *\n * @defaultValue false\n *\n * @example\n * ```ts\n * import { prettyBytes } from '@stryke/string-fns/pretty-bytes';\n *\n * prettyBytes(1337, {bits: true});\n * //=> '1.34 kbit'\n * ```\n */\n readonly bits?: boolean;\n\n /**\n * Format the number using the [Binary Prefix](https://en.wikipedia.org/wiki/Binary_prefix) instead of the [SI Prefix](https://en.wikipedia.org/wiki/SI_prefix). This can be useful for presenting memory amounts. However, this should not be used for presenting file sizes.\n *\n * @defaultValue false\n *\n * @example\n * ```ts\n * import { prettyBytes } from '@stryke/string-fns/pretty-bytes';\n *\n * prettyBytes(1000, {binary: true});\n * //=> '1000 bit'\n *\n * prettyBytes(1024, {binary: true});\n * //=> '1 kiB'\n * ```\n */\n readonly binary?: boolean;\n\n /**\n * The minimum number of fraction digits to display.\n *\n * If neither `minimumFractionDigits` or `maximumFractionDigits` are set, the default behavior is to round to 3 significant digits.\n *\n * @defaultValue undefined\n *\n * @example\n * ```ts\n * import { prettyBytes } from '@stryke/string-fns/pretty-bytes';\n *\n * // Show the number with at least 3 fractional digits\n * prettyBytes(1900, {minimumFractionDigits: 3});\n * //=> '1.900 kB'\n *\n * prettyBytes(1900);\n * //=> '1.9 kB'\n * ```\n */\n readonly minimumFractionDigits?: number;\n\n /**\n * The maximum number of fraction digits to display.\n *\n * If neither `minimumFractionDigits` or `maximumFractionDigits` are set, the default behavior is to round to 3 significant digits.\n *\n * @defaultValue undefined\n *\n * @example\n * ```ts\n * import { prettyBytes } from '@stryke/string-fns/pretty-bytes';\n *\n * // Show the number with at most 1 fractional digit\n * prettyBytes(1920, {maximumFractionDigits: 1});\n * //=> '1.9 kB'\n *\n * prettyBytes(1920);\n * //=> '1.92 kB'\n * ```\n */\n readonly maximumFractionDigits?: number;\n\n /**\n * Put a space between the number and unit.\n *\n * @defaultValue true\n *\n * @example\n * ```ts\n * import { prettyBytes } from '@stryke/string-fns/pretty-bytes';\n *\n * prettyBytes(1920, {space: false});\n * //=> '1.9kB'\n *\n * prettyBytes(1920);\n * //=> '1.92 kB'\n * ```\n */\n readonly space?: boolean;\n}\n\nconst BYTE_UNITS = [\"B\", \"kB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"];\nconst BIBYTE_UNITS = [\n \"B\",\n \"KiB\",\n \"MiB\",\n \"GiB\",\n \"TiB\",\n \"PiB\",\n \"EiB\",\n \"ZiB\",\n \"YiB\"\n];\nconst BIT_UNITS = [\n \"b\",\n \"kbit\",\n \"Mbit\",\n \"Gbit\",\n \"Tbit\",\n \"Pbit\",\n \"Ebit\",\n \"Zbit\",\n \"Ybit\"\n];\nconst BIBIT_UNITS = [\n \"b\",\n \"kibit\",\n \"Mibit\",\n \"Gibit\",\n \"Tibit\",\n \"Pibit\",\n \"Eibit\",\n \"Zibit\",\n \"Yibit\"\n];\n\n/**\n * Formats the given number using `Number#toLocaleString`.\n *\n * @remarks\n * - If locale is a string, the value is expected to be a locale-key (for example: `de`).\n * - If locale is true, the system default locale is used for translation.\n * - If no value for locale is specified, the number is returned unmodified.\n *\n * @param number - The number to format.\n * @param locale - The locale to use for formatting the number.\n * @param options - The options to use for formatting the number.\n * @returns The formatted number.\n */\nexport const toLocaleString = (\n number?: number | string,\n locale?: string | readonly string[] | boolean,\n options: Options = {}\n): string => {\n let result = number;\n let _locale = locale;\n if (typeof _locale === \"string\") {\n if (!_locale) {\n _locale = process.env.STORM_LOCALE || \"en-US\";\n }\n if (Array.isArray(_locale)) {\n result = number?.toLocaleString(_locale, options);\n }\n } else if (_locale === true || options !== undefined) {\n result = number?.toLocaleString(undefined, options);\n }\n\n return String(result);\n};\n\n/**\n * Convert bytes to a human readable string: `1337` → `1.34 kB`.\n *\n * @param number - The number to format.\n *\n * @example\n * ```ts\n * import { prettyBytes } from '@stryke/string-fns/pretty-bytes';\n *\n * prettyBytes(1337);\n * //=> '1.34 kB'\n *\n * prettyBytes(100);\n * //=> '100 B'\n *\n * // Display file size differences\n * prettyBytes(42, {signed: true});\n * //=> '+42 B'\n *\n * // Localized output using German locale\n * prettyBytes(1337, {locale: 'de'});\n * //=> '1,34 kB'\n * ```\n *\n * @param number - The number to format.\n * @param options - The options to use.\n * @returns The formatted string.\n */\nexport function prettyBytes(number: number, options?: Options): string {\n let _number: string | number = number;\n if (!Number.isFinite(_number)) {\n throw new TypeError(\n `Expected a finite number, got ${typeof _number}: ${_number}`\n );\n }\n\n const opts = {\n bits: false,\n binary: false,\n space: true,\n ...options\n };\n\n const UNITS = opts.bits\n ? opts.binary\n ? BIBIT_UNITS\n : BIT_UNITS\n : opts.binary\n ? BIBYTE_UNITS\n : BYTE_UNITS;\n\n const separator = opts.space ? \" \" : \"\";\n\n if (opts.signed && _number === 0) {\n return ` 0${separator}${UNITS[0]}`;\n }\n\n const isNegative = _number < 0;\n\n const prefix = isNegative ? \"-\" : opts.signed ? \"+\" : \"\";\n\n if (isNegative) {\n _number = -_number;\n }\n\n let localeOptions;\n\n if (opts.minimumFractionDigits !== undefined) {\n localeOptions = { minimumFractionDigits: opts.minimumFractionDigits };\n }\n\n if (opts.maximumFractionDigits !== undefined) {\n localeOptions = {\n maximumFractionDigits: opts.maximumFractionDigits,\n ...localeOptions\n };\n }\n\n if (_number < 1) {\n const numberString = toLocaleString(_number, opts.locale, localeOptions);\n\n return prefix + numberString + separator + UNITS[0];\n }\n\n const exponent = Math.min(\n Math.floor(\n opts.binary ? Math.log(_number) / Math.log(1024) : Math.log10(_number) / 3\n ),\n UNITS.length - 1\n );\n _number /= (opts.binary ? 1024 : 1000) ** exponent;\n\n if (!localeOptions) {\n _number = _number.toPrecision(3);\n }\n\n const numberString = toLocaleString(\n Number(_number),\n opts.locale,\n localeOptions\n );\n\n const unit = UNITS[exponent];\n\n return prefix + numberString + separator + unit;\n}\n"],"mappings":"AAkIA,MAAM,EAAa,CAAC,IAAK,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,KAAK,CAClE,EAAe,CACnB,IACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACD,CACK,EAAY,CAChB,IACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACD,CACK,EAAc,CAClB,IACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACD,CAeY,GACX,EACA,EACA,EAAmB,EAAE,GACV,CACX,IAAI,EAAS,EACT,EAAU,EAYd,OAXI,OAAO,GAAY,UACrB,AACE,IAAU,QAAQ,IAAI,cAAgB,QAEpC,MAAM,QAAQ,EAAQ,GACxB,EAAS,GAAQ,eAAe,EAAS,EAAQ,IAE1C,IAAY,IAAQ,IAAY,IAAA,MACzC,EAAS,GAAQ,eAAe,IAAA,GAAW,EAAQ,EAG9C,OAAO,EAAO,EA+BvB,SAAgB,EAAY,EAAgB,EAA2B,CACrE,IAAIA,EAA2B,EAC/B,GAAI,CAAC,OAAO,SAAS,EAAQ,CAC3B,MAAU,UACR,iCAAiC,OAAO,EAAQ,IAAI,IACrD,CAGH,IAAM,EAAO,CACX,KAAM,GACN,OAAQ,GACR,MAAO,GACP,GAAG,EACJ,CAEK,EAAQ,EAAK,KACf,EAAK,OACH,EACA,EACF,EAAK,OACH,EACA,EAEA,EAAY,EAAK,MAAQ,IAAM,GAErC,GAAI,EAAK,QAAU,IAAY,EAC7B,MAAO,KAAK,IAAY,EAAM,KAGhC,IAAM,EAAa,EAAU,EAEvB,EAAS,EAAa,IAAM,EAAK,OAAS,IAAM,GAElD,IACF,EAAU,CAAC,GAGb,IAAI,EAaJ,GAXI,EAAK,wBAA0B,IAAA,KACjC,EAAgB,CAAE,sBAAuB,EAAK,sBAAuB,EAGnE,EAAK,wBAA0B,IAAA,KACjC,EAAgB,CACd,sBAAuB,EAAK,sBAC5B,GAAG,EACJ,EAGC,EAAU,EAGZ,OAAO,EAFc,EAAe,EAAS,EAAK,OAAQ,EAAc,CAEzC,EAAY,EAAM,GAGnD,IAAM,EAAW,KAAK,IACpB,KAAK,MACH,EAAK,OAAS,KAAK,IAAI,EAAQ,CAAG,KAAK,IAAI,KAAK,CAAG,KAAK,MAAM,EAAQ,CAAG,EAC1E,CACD,EAAM,OAAS,EAChB,CACD,IAAY,EAAK,OAAS,KAAO,MAAS,EAErC,IACH,EAAU,EAAQ,YAAY,EAAE,EAGlC,IAAM,EAAe,EACnB,OAAO,EAAQ,CACf,EAAK,OACL,EACD,CAEK,EAAO,EAAM,GAEnB,OAAO,EAAS,EAAe,EAAY"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
//#region src/pretty-bytes.d.ts
|
|
2
|
+
interface Options {
|
|
3
|
+
/**
|
|
4
|
+
* Include plus sign for positive numbers. If the difference is exactly zero a space character will be prepended instead for better alignment.
|
|
5
|
+
*
|
|
6
|
+
* @defaultValue false
|
|
7
|
+
*/
|
|
8
|
+
readonly signed?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* - If `false`: Output won't be localized.
|
|
11
|
+
* - If `true`: Localize the output using the system/browser locale.
|
|
12
|
+
* - If `string`: Expects a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
|
|
13
|
+
* - If `string[]`: Expects a list of [BCP 47 language tags](https://en.wikipedia.org/wiki/IETF_language_tag) (For example: `en`, `de`, …)
|
|
14
|
+
*
|
|
15
|
+
* @defaultValue false
|
|
16
|
+
*/
|
|
17
|
+
readonly locale?: boolean | string | readonly string[];
|
|
18
|
+
/**
|
|
19
|
+
* Format the number as [bits](https://en.wikipedia.org/wiki/Bit) instead of [bytes](https://en.wikipedia.org/wiki/Byte). This can be useful when, for example, referring to [bit rate](https://en.wikipedia.org/wiki/Bit_rate).
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue false
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
26
|
+
*
|
|
27
|
+
* prettyBytes(1337, {bits: true});
|
|
28
|
+
* //=> '1.34 kbit'
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
readonly bits?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Format the number using the [Binary Prefix](https://en.wikipedia.org/wiki/Binary_prefix) instead of the [SI Prefix](https://en.wikipedia.org/wiki/SI_prefix). This can be useful for presenting memory amounts. However, this should not be used for presenting file sizes.
|
|
34
|
+
*
|
|
35
|
+
* @defaultValue false
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
40
|
+
*
|
|
41
|
+
* prettyBytes(1000, {binary: true});
|
|
42
|
+
* //=> '1000 bit'
|
|
43
|
+
*
|
|
44
|
+
* prettyBytes(1024, {binary: true});
|
|
45
|
+
* //=> '1 kiB'
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
readonly binary?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The minimum number of fraction digits to display.
|
|
51
|
+
*
|
|
52
|
+
* If neither `minimumFractionDigits` or `maximumFractionDigits` are set, the default behavior is to round to 3 significant digits.
|
|
53
|
+
*
|
|
54
|
+
* @defaultValue undefined
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
59
|
+
*
|
|
60
|
+
* // Show the number with at least 3 fractional digits
|
|
61
|
+
* prettyBytes(1900, {minimumFractionDigits: 3});
|
|
62
|
+
* //=> '1.900 kB'
|
|
63
|
+
*
|
|
64
|
+
* prettyBytes(1900);
|
|
65
|
+
* //=> '1.9 kB'
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
readonly minimumFractionDigits?: number;
|
|
69
|
+
/**
|
|
70
|
+
* The maximum number of fraction digits to display.
|
|
71
|
+
*
|
|
72
|
+
* If neither `minimumFractionDigits` or `maximumFractionDigits` are set, the default behavior is to round to 3 significant digits.
|
|
73
|
+
*
|
|
74
|
+
* @defaultValue undefined
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
79
|
+
*
|
|
80
|
+
* // Show the number with at most 1 fractional digit
|
|
81
|
+
* prettyBytes(1920, {maximumFractionDigits: 1});
|
|
82
|
+
* //=> '1.9 kB'
|
|
83
|
+
*
|
|
84
|
+
* prettyBytes(1920);
|
|
85
|
+
* //=> '1.92 kB'
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
readonly maximumFractionDigits?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Put a space between the number and unit.
|
|
91
|
+
*
|
|
92
|
+
* @defaultValue true
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
97
|
+
*
|
|
98
|
+
* prettyBytes(1920, {space: false});
|
|
99
|
+
* //=> '1.9kB'
|
|
100
|
+
*
|
|
101
|
+
* prettyBytes(1920);
|
|
102
|
+
* //=> '1.92 kB'
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
readonly space?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Formats the given number using `Number#toLocaleString`.
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* - If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
|
112
|
+
* - If locale is true, the system default locale is used for translation.
|
|
113
|
+
* - If no value for locale is specified, the number is returned unmodified.
|
|
114
|
+
*
|
|
115
|
+
* @param number - The number to format.
|
|
116
|
+
* @param locale - The locale to use for formatting the number.
|
|
117
|
+
* @param options - The options to use for formatting the number.
|
|
118
|
+
* @returns The formatted number.
|
|
119
|
+
*/
|
|
120
|
+
declare const toLocaleString: (number?: number | string, locale?: string | readonly string[] | boolean, options?: Options) => string;
|
|
121
|
+
/**
|
|
122
|
+
* Convert bytes to a human readable string: `1337` → `1.34 kB`.
|
|
123
|
+
*
|
|
124
|
+
* @param number - The number to format.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
129
|
+
*
|
|
130
|
+
* prettyBytes(1337);
|
|
131
|
+
* //=> '1.34 kB'
|
|
132
|
+
*
|
|
133
|
+
* prettyBytes(100);
|
|
134
|
+
* //=> '100 B'
|
|
135
|
+
*
|
|
136
|
+
* // Display file size differences
|
|
137
|
+
* prettyBytes(42, {signed: true});
|
|
138
|
+
* //=> '+42 B'
|
|
139
|
+
*
|
|
140
|
+
* // Localized output using German locale
|
|
141
|
+
* prettyBytes(1337, {locale: 'de'});
|
|
142
|
+
* //=> '1,34 kB'
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @param number - The number to format.
|
|
146
|
+
* @param options - The options to use.
|
|
147
|
+
* @returns The formatted string.
|
|
148
|
+
*/
|
|
149
|
+
declare function prettyBytes(number: number, options?: Options): string;
|
|
150
|
+
//#endregion
|
|
151
|
+
export { prettyBytes as n, toLocaleString as r, Options as t };
|
|
152
|
+
//# sourceMappingURL=pretty-bytes-Dv8t5D6N.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pretty-bytes-Dv8t5D6N.d.cts","names":[],"sources":["../src/pretty-bytes.ts"],"sourcesContent":[],"mappings":";UAkBiB,OAAA;EAAA;AAgKjB;AAiDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAjDa,oGAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8CK,WAAA,2BAAsC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=[`B`,`kB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],t=[`B`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],n=[`b`,`kbit`,`Mbit`,`Gbit`,`Tbit`,`Pbit`,`Ebit`,`Zbit`,`Ybit`],r=[`b`,`kibit`,`Mibit`,`Gibit`,`Tibit`,`Pibit`,`Eibit`,`Zibit`,`Yibit`],i=(e,t,n={})=>{let r=e,i=t;return typeof i==`string`?(i||=process.env.STORM_LOCALE||`en-US`,Array.isArray(i)&&(r=e?.toLocaleString(i,n))):(i===!0||n!==void 0)&&(r=e?.toLocaleString(void 0,n)),String(r)};function a(a,o){let s=a;if(!Number.isFinite(s))throw TypeError(`Expected a finite number, got ${typeof s}: ${s}`);let c={bits:!1,binary:!1,space:!0,...o},l=c.bits?c.binary?r:n:c.binary?t:e,u=c.space?` `:``;if(c.signed&&s===0)return` 0${u}${l[0]}`;let d=s<0,f=d?`-`:c.signed?`+`:``;d&&(s=-s);let p;if(c.minimumFractionDigits!==void 0&&(p={minimumFractionDigits:c.minimumFractionDigits}),c.maximumFractionDigits!==void 0&&(p={maximumFractionDigits:c.maximumFractionDigits,...p}),s<1)return f+i(s,c.locale,p)+u+l[0];let m=Math.min(Math.floor(c.binary?Math.log(s)/Math.log(1024):Math.log10(s)/3),l.length-1);s/=(c.binary?1024:1e3)**m,p||(s=s.toPrecision(3));let h=i(Number(s),c.locale,p),g=l[m];return f+h+u+g}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
|
package/dist/pretty-bytes.cjs
CHANGED
|
@@ -1,48 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.prettyBytes = prettyBytes;
|
|
7
|
-
exports.toLocaleString = void 0;
|
|
8
|
-
const u = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
|
|
9
|
-
B = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"],
|
|
10
|
-
f = ["b", "kbit", "Mbit", "Gbit", "Tbit", "Pbit", "Ebit", "Zbit", "Ybit"],
|
|
11
|
-
y = ["b", "kibit", "Mibit", "Gibit", "Tibit", "Pibit", "Eibit", "Zibit", "Yibit"];
|
|
12
|
-
const toLocaleString = (r, o, i = {}) => {
|
|
13
|
-
let t = r,
|
|
14
|
-
n = o;
|
|
15
|
-
return typeof n == "string" ? (n || (n = process.env.STORM_LOCALE || "en-US"), Array.isArray(n) && (t = r?.toLocaleString(n, i))) : (n === !0 || i !== void 0) && (t = r?.toLocaleString(void 0, i)), String(t);
|
|
16
|
-
};
|
|
17
|
-
exports.toLocaleString = toLocaleString;
|
|
18
|
-
function prettyBytes(r, o) {
|
|
19
|
-
let i = r;
|
|
20
|
-
if (!Number.isFinite(i)) throw new TypeError(`Expected a finite number, got ${typeof i}: ${i}`);
|
|
21
|
-
const t = {
|
|
22
|
-
bits: !1,
|
|
23
|
-
binary: !1,
|
|
24
|
-
space: !0,
|
|
25
|
-
...o
|
|
26
|
-
},
|
|
27
|
-
n = t.bits ? t.binary ? y : f : t.binary ? B : u,
|
|
28
|
-
a = t.space ? " " : "";
|
|
29
|
-
if (t.signed && i === 0) return ` 0${a}${n[0]}`;
|
|
30
|
-
const s = i < 0,
|
|
31
|
-
b = s ? "-" : t.signed ? "+" : "";
|
|
32
|
-
s && (i = -i);
|
|
33
|
-
let e;
|
|
34
|
-
if (t.minimumFractionDigits !== void 0 && (e = {
|
|
35
|
-
minimumFractionDigits: t.minimumFractionDigits
|
|
36
|
-
}), t.maximumFractionDigits !== void 0 && (e = {
|
|
37
|
-
maximumFractionDigits: t.maximumFractionDigits,
|
|
38
|
-
...e
|
|
39
|
-
}), i < 1) {
|
|
40
|
-
const g = toLocaleString(i, t.locale, e);
|
|
41
|
-
return b + g + a + n[0];
|
|
42
|
-
}
|
|
43
|
-
const l = Math.min(Math.floor(t.binary ? Math.log(i) / Math.log(1024) : Math.log10(i) / 3), n.length - 1);
|
|
44
|
-
i /= (t.binary ? 1024 : 1e3) ** l, e || (i = i.toPrecision(3));
|
|
45
|
-
const c = toLocaleString(Number(i), t.locale, e),
|
|
46
|
-
m = n[l];
|
|
47
|
-
return b + c + a + m;
|
|
48
|
-
}
|
|
1
|
+
const e=require(`./pretty-bytes-aHFwwFbw.cjs`);exports.prettyBytes=e.t,exports.toLocaleString=e.n;
|
package/dist/pretty-bytes.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{n as e,t}from"./pretty-bytes-DmvsumO5.mjs";export{t as prettyBytes,e as toLocaleString};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/snake-case.d.ts
|
|
2
|
+
interface SnakeCaseOptions {
|
|
3
|
+
splitOnNumber: boolean;
|
|
3
4
|
}
|
|
4
5
|
/**
|
|
5
6
|
* Check if the input string is in snake case.
|
|
@@ -10,7 +11,7 @@ export interface SnakeCaseOptions {
|
|
|
10
11
|
* @param input - The input string to check.
|
|
11
12
|
* @returns True if the input is in snake case, false otherwise.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
declare function isSnakeCase(input: string | undefined): boolean;
|
|
14
15
|
/**
|
|
15
16
|
* Convert the input string to snake case.
|
|
16
17
|
*
|
|
@@ -21,4 +22,7 @@ export declare function isSnakeCase(input: string | undefined): boolean;
|
|
|
21
22
|
* @param options - Options to control the behavior of the function.
|
|
22
23
|
* @returns The snake-cased string.
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
declare function snakeCase<T extends string | undefined>(input: T, options?: SnakeCaseOptions): T;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { isSnakeCase as n, snakeCase as r, SnakeCaseOptions as t };
|
|
28
|
+
//# sourceMappingURL=snake-case-C5v7aTGP.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snake-case-C5v7aTGP.d.cts","names":[],"sources":["../src/snake-case.ts"],"sourcesContent":[],"mappings":";UAsBiB,gBAAA;EAAA,aAAA,EAAA,OAAgB;AAajC;AAcA;;;;;;;;;iBAdgB,WAAA;;;;;;;;;;;iBAcA,+CACP,aACG,mBACT"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/snake-case.d.ts
|
|
2
|
+
interface SnakeCaseOptions {
|
|
3
|
+
splitOnNumber: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Check if the input string is in snake case.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Snake case is defined as all lowercase letters with underscores separating words - "this_is_an_example"
|
|
10
|
+
*
|
|
11
|
+
* @param input - The input string to check.
|
|
12
|
+
* @returns True if the input is in snake case, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
declare function isSnakeCase(input: string | undefined): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Convert the input string to snake case.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* Snake case is defined as all lowercase letters with underscores separating words - "this_is_an_example"
|
|
20
|
+
*
|
|
21
|
+
* @param input - The input string.
|
|
22
|
+
* @param options - Options to control the behavior of the function.
|
|
23
|
+
* @returns The snake-cased string.
|
|
24
|
+
*/
|
|
25
|
+
declare function snakeCase<T extends string | undefined>(input: T, options?: SnakeCaseOptions): T;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { isSnakeCase as n, snakeCase as r, SnakeCaseOptions as t };
|
|
28
|
+
//# sourceMappingURL=snake-case-CKf8oDuS.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snake-case-CKf8oDuS.d.mts","names":[],"sources":["../src/snake-case.ts"],"sourcesContent":[],"mappings":";UAsBiB,gBAAA;EAAA,aAAA,EAAA,OAAgB;AAajC;AAcA;;;;;;;;;iBAdgB,WAAA;;;;;;;;;;;iBAcA,+CACP,aACG,mBACT"}
|
package/dist/snake-case.cjs
CHANGED
|
@@ -1,22 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isSnakeCase = isSnakeCase;
|
|
7
|
-
exports.snakeCase = snakeCase;
|
|
8
|
-
var _types = require("@stryke/types");
|
|
9
|
-
var _constantCase = require("./constant-case.cjs");
|
|
10
|
-
var _upperCaseFirst = require("./upper-case-first.cjs");
|
|
11
|
-
function isSnakeCase(e) {
|
|
12
|
-
return e ? /^[a-z]+(?:_[a-z0-9]+)*$/.test(e) : !1;
|
|
13
|
-
}
|
|
14
|
-
function snakeCase(e, n) {
|
|
15
|
-
if (isSnakeCase(e) || e === void 0) return e;
|
|
16
|
-
if ((0, _constantCase.isConstantCase)(e)) return e.toLowerCase();
|
|
17
|
-
const s = e?.replace(/[A-Z]+/g, r => (0, _upperCaseFirst.upperCaseFirst)(r) ?? _types.EMPTY_STRING).split(/(?=[A-Z])|[\s._-]/).map(r => r.toLowerCase()) ?? [];
|
|
18
|
-
if (s.length === 0) return "";
|
|
19
|
-
if (s.length === 1) return s[0];
|
|
20
|
-
const t = s.reduce((r, a) => `${r}_${a.toLowerCase()}`);
|
|
21
|
-
return n?.splitOnNumber === !1 ? t : t.replace(/[A-Z]\d/i, r => `${r[0]}_${r[1]}`);
|
|
22
|
-
}
|
|
1
|
+
const e=require(`./constant-case-B0oTEBjC.cjs`);exports.isSnakeCase=e.r,exports.snakeCase=e.i;
|
package/dist/snake-case.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{i as e,r as t}from"./constant-case-Cn0OS_D5.mjs";export{t as isSnakeCase,e as snakeCase};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"special-cases-Ab3-SD5v.d.cts","names":[],"sources":["../src/special-cases.ts"],"sourcesContent":[],"mappings":";cAkBa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=`2FA.4K.5K.8K.AGI.BI.ChatGPT.CTA.DateTime.FMS.GitHub.GPT.HD.IBMid.IDs.iMac.IMAX.iOS.iPad.iPhone.iPod.LDAP.LinkedIn.LLM.macOS.McDonalds.MCP.ML.MySQL.NLG.NLP.NLU.OpenAI.PDFs.PIM.PEFT.pH.PostgreSQL.SEO.TTS.UHD.UUID.XSS.YouTube.CSpell.ESLint`.split(`.`);Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"special-cases-D7iFXvkR.d.mts","names":[],"sources":["../src/special-cases.ts"],"sourcesContent":[],"mappings":";cAkBa"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=`2FA.4K.5K.8K.AGI.BI.ChatGPT.CTA.DateTime.FMS.GitHub.GPT.HD.IBMid.IDs.iMac.IMAX.iOS.iPad.iPhone.iPod.LDAP.LinkedIn.LLM.macOS.McDonalds.MCP.ML.MySQL.NLG.NLP.NLU.OpenAI.PDFs.PIM.PEFT.pH.PostgreSQL.SEO.TTS.UHD.UUID.XSS.YouTube.CSpell.ESLint`.split(`.`);export{e as t};
|
|
2
|
+
//# sourceMappingURL=special-cases-gNNOSEbK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"special-cases-gNNOSEbK.mjs","names":[],"sources":["../src/special-cases.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const SPECIAL_CASES = [\n \"2FA\",\n \"4K\",\n \"5K\",\n \"8K\",\n \"AGI\",\n \"BI\",\n \"ChatGPT\",\n \"CTA\",\n \"DateTime\",\n \"FMS\",\n \"GitHub\",\n \"GPT\",\n \"HD\",\n \"IBMid\",\n \"IDs\",\n \"iMac\",\n \"IMAX\",\n \"iOS\",\n \"iPad\",\n \"iPhone\",\n \"iPod\",\n \"LDAP\",\n \"LinkedIn\",\n \"LLM\",\n \"macOS\",\n \"McDonalds\",\n \"MCP\",\n \"ML\",\n \"MySQL\",\n \"NLG\",\n \"NLP\",\n \"NLU\",\n \"OpenAI\",\n \"PDFs\",\n \"PIM\",\n \"PEFT\",\n \"pH\",\n \"PostgreSQL\",\n \"SEO\",\n \"TTS\",\n \"UHD\",\n \"UUID\",\n \"XSS\",\n \"YouTube\",\n \"CSpell\",\n \"ESLint\"\n];\n"],"mappings":"AAkBA,MAAa,EAAgB,yPA+C5B"}
|
package/dist/special-cases.cjs
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SPECIAL_CASES = void 0;
|
|
7
|
-
const SPECIAL_CASES = exports.SPECIAL_CASES = ["2FA", "4K", "5K", "8K", "AGI", "BI", "ChatGPT", "CTA", "DateTime", "FMS", "GitHub", "GPT", "HD", "IBMid", "IDs", "iMac", "IMAX", "iOS", "iPad", "iPhone", "iPod", "LDAP", "LinkedIn", "LLM", "macOS", "McDonalds", "MCP", "ML", "MySQL", "NLG", "NLP", "NLU", "OpenAI", "PDFs", "PIM", "PEFT", "pH", "PostgreSQL", "SEO", "TTS", "UHD", "UUID", "XSS", "YouTube", "CSpell", "ESLint"];
|
|
1
|
+
const e=require(`./special-cases-CfBSDTk8.cjs`);exports.SPECIAL_CASES=e.t;
|
package/dist/special-cases.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{t as e}from"./special-cases-gNNOSEbK.mjs";export{e as SPECIAL_CASES};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/start-case.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Check if the input string is in snake case.
|
|
3
4
|
*
|
|
@@ -7,7 +8,7 @@
|
|
|
7
8
|
* @param input - The input string to check.
|
|
8
9
|
* @returns True if the input is in start case, false otherwise.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
declare function isStartCase(input: string | undefined): boolean;
|
|
11
12
|
/**
|
|
12
13
|
* Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.
|
|
13
14
|
*
|
|
@@ -25,4 +26,7 @@ export declare function isStartCase(input: string | undefined): boolean;
|
|
|
25
26
|
* @param input - The string to convert.
|
|
26
27
|
* @returns The converted string.
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
+
declare function startCase<T extends string | undefined>(input?: T): T;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { startCase as n, isStartCase as t };
|
|
32
|
+
//# sourceMappingURL=start-case-B9JLArn_.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-case-B9JLArn_.d.mts","names":[],"sources":["../src/start-case.ts"],"sourcesContent":[],"mappings":";;AA6BA;AAqBA;;;;;;;iBArBgB,WAAA;;;;;;;;;;;;;;;;;;iBAqBA,gDAAgD,IAAI"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./get-words-vlruPM_Q.mjs";function t(e){return e?/^[A-Z][a-z]*(?: [A-Z][a-z]*)*$/.test(e):!1}function n(n){if(t(n)||n===void 0)return n;let r=e(n.trim()),i=``;for(let e of r)e&&e[0]&&(i&&(i+=` `),i+=e===e.toUpperCase()?e:e[0].toUpperCase()+e.slice(1).toLowerCase());return i}export{n,t};
|
|
2
|
+
//# sourceMappingURL=start-case-CbdCqiBN.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-case-CbdCqiBN.mjs","names":[],"sources":["../src/start-case.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getWords } from \"./get-words\";\n\n/**\n * Check if the input string is in snake case.\n *\n * @remarks\n * Start case is the naming convention in which each word is written with an initial capital letter - \"This Is An Example\".\n *\n * @param input - The input string to check.\n * @returns True if the input is in start case, false otherwise.\n */\nexport function isStartCase(input: string | undefined): boolean {\n return input ? /^[A-Z][a-z]*(?: [A-Z][a-z]*)*$/.test(input) : false;\n}\n\n/**\n * Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.\n *\n * @remarks\n * Start case is the naming convention in which each word is written with an initial capital letter - \"This Is An Example\".\n *\n * @example\n * ```ts\n * const result1 = startCase('hello world'); // result will be 'Hello World'\n * const result2 = startCase('HELLO WORLD'); // result will be 'Hello World'\n * const result3 = startCase('hello-world'); // result will be 'Hello World'\n * const result4 = startCase('hello_world'); // result will be 'Hello World'\n * ```\n *\n * @param input - The string to convert.\n * @returns The converted string.\n */\nexport function startCase<T extends string | undefined>(input?: T): T {\n if (isStartCase(input) || input === undefined) {\n return input as T;\n }\n\n const words = getWords(input.trim());\n\n let result = \"\";\n for (const word of words) {\n if (word && word[0]) {\n if (result) {\n result += \" \";\n }\n\n result +=\n word === word.toUpperCase()\n ? word\n : word[0].toUpperCase() + word.slice(1).toLowerCase();\n }\n }\n\n return result as T;\n}\n"],"mappings":"6CA6BA,SAAgB,EAAY,EAAoC,CAC9D,OAAO,EAAQ,iCAAiC,KAAK,EAAM,CAAG,GAoBhE,SAAgB,EAAwC,EAAc,CACpE,GAAI,EAAY,EAAM,EAAI,IAAU,IAAA,GAClC,OAAO,EAGT,IAAM,EAAQ,EAAS,EAAM,MAAM,CAAC,CAEhC,EAAS,GACb,IAAK,IAAM,KAAQ,EACb,GAAQ,EAAK,KACX,IACF,GAAU,KAGZ,GACE,IAAS,EAAK,aAAa,CACvB,EACA,EAAK,GAAG,aAAa,CAAG,EAAK,MAAM,EAAE,CAAC,aAAa,EAI7D,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./get-words-IF97Rpfr.cjs`);function t(e){return e?/^[A-Z][a-z]*(?: [A-Z][a-z]*)*$/.test(e):!1}function n(n){if(t(n)||n===void 0)return n;let r=e.r(n.trim()),i=``;for(let e of r)e&&e[0]&&(i&&(i+=` `),i+=e===e.toUpperCase()?e:e[0].toUpperCase()+e.slice(1).toLowerCase());return i}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|