@rzl-zone/utils-js 3.13.0 → 3.13.1
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/dist/.references/index.d.cts +1 -1
- package/dist/.references/index.d.ts +1 -1
- package/dist/{assertIsArray-BgdgVjDu.cjs → assertIsArray-CeXL4xv5.cjs} +3 -3
- package/dist/{assertIsArray-BgdgVjDu.cjs.map → assertIsArray-CeXL4xv5.cjs.map} +1 -1
- package/dist/{assertIsArray-hZyYKvLb.js → assertIsArray-HgzPQIAM.js} +3 -3
- package/dist/{assertIsArray-hZyYKvLb.js.map → assertIsArray-HgzPQIAM.js.map} +1 -1
- package/dist/{assertIsBoolean-9-huIcIR.js → assertIsBoolean-CWUs-I5l.js} +2 -2
- package/dist/{assertIsBoolean-9-huIcIR.js.map → assertIsBoolean-CWUs-I5l.js.map} +1 -1
- package/dist/{assertIsBoolean-JGpkg5ju.cjs → assertIsBoolean-D41HrTB_.cjs} +2 -2
- package/dist/{assertIsBoolean-JGpkg5ju.cjs.map → assertIsBoolean-D41HrTB_.cjs.map} +1 -1
- package/dist/{assertIsString-CcOpQqcv.js → assertIsString-CY_WkCLr.js} +3 -3
- package/dist/{assertIsString-CcOpQqcv.js.map → assertIsString-CY_WkCLr.js.map} +1 -1
- package/dist/{assertIsString-UR6QjqyZ.cjs → assertIsString-DUrVt82d.cjs} +3 -3
- package/dist/{assertIsString-UR6QjqyZ.cjs.map → assertIsString-DUrVt82d.cjs.map} +1 -1
- package/dist/assertions/index.cjs +5 -5
- package/dist/assertions/index.cjs.map +1 -1
- package/dist/assertions/index.d.cts +2 -2
- package/dist/assertions/index.d.ts +2 -2
- package/dist/assertions/index.js +5 -5
- package/dist/assertions/index.js.map +1 -1
- package/dist/conversions/index.cjs +6 -6
- package/dist/conversions/index.d.cts +2 -2
- package/dist/conversions/index.d.ts +2 -2
- package/dist/conversions/index.js +6 -6
- package/dist/{conversions-Du6GC5JA.js → conversions-1s7xMBe_.js} +12 -12
- package/dist/{conversions-Du6GC5JA.js.map → conversions-1s7xMBe_.js.map} +1 -1
- package/dist/{conversions-DLt2zlyu.cjs → conversions-B3Rf8uId.cjs} +12 -12
- package/dist/{conversions-DLt2zlyu.cjs.map → conversions-B3Rf8uId.cjs.map} +1 -1
- package/dist/events/index.cjs +4 -4
- package/dist/events/index.cjs.map +1 -1
- package/dist/events/index.d.cts +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +4 -4
- package/dist/events/index.js.map +1 -1
- package/dist/formatters/index.cjs +2 -2
- package/dist/formatters/index.d.cts +2 -2
- package/dist/formatters/index.d.ts +2 -2
- package/dist/formatters/index.js +2 -2
- package/dist/{formatters-RomzqDp_.js → formatters-C6cVZBbG.js} +10 -10
- package/dist/{formatters-RomzqDp_.js.map → formatters-C6cVZBbG.js.map} +1 -1
- package/dist/{formatters-C0t5CdX-.cjs → formatters-aEAAuzjx.cjs} +10 -10
- package/dist/{formatters-C0t5CdX-.cjs.map → formatters-aEAAuzjx.cjs.map} +1 -1
- package/dist/generators/index.cjs +5 -5
- package/dist/generators/index.cjs.map +1 -1
- package/dist/generators/index.d.cts +2 -2
- package/dist/generators/index.d.ts +2 -2
- package/dist/generators/index.js +5 -5
- package/dist/generators/index.js.map +1 -1
- package/dist/{index-50G4edI1.d.ts → index-B1VQ6USF.d.ts} +2 -2
- package/dist/{index-BcKPWWfh.d.ts → index-B5EBAgmC.d.cts} +2 -2
- package/dist/{index-tYmZ3X4Y.d.cts → index-BG8wdusZ.d.cts} +2 -2
- package/dist/{index-CPc-TTMc.d.cts → index-CPCt6_Wq.d.cts} +1 -1
- package/dist/{index-hsSSKuvW.d.ts → index-CPCt6_Wq.d.ts} +1 -1
- package/dist/{index-B6Xg9Z8l.d.ts → index-CRz9rSZL.d.ts} +1 -1
- package/dist/{index-DoteSYTy.d.cts → index-DBwNa1iO.d.ts} +3 -3
- package/dist/{index-s7h0w-8H.d.cts → index-DPJ-e2JZ.d.ts} +2 -2
- package/dist/{index-bGRsmkyA.d.ts → index-DPTYOQkn.d.cts} +3 -3
- package/dist/{index-DM_0q4CY.d.cts → index-Dig1fIhZ.d.cts} +1 -1
- package/dist/{index-5DpyzfpU.d.ts → index-Dig1fIhZ.d.ts} +1 -1
- package/dist/{index-BFI4R7Pn.d.ts → index-ORbo-7zA.d.cts} +1 -1
- package/dist/{index-D-5AsV9K.d.cts → index-ORbo-7zA.d.ts} +1 -1
- package/dist/{index-CMcxcN7w.d.cts → index-RNQBTK8A.d.cts} +1 -1
- package/dist/{isBigInt-C0gHDkh4.cjs → isBigInt-BVj0M5pq.cjs} +2 -2
- package/dist/{isBigInt-C0gHDkh4.cjs.map → isBigInt-BVj0M5pq.cjs.map} +1 -1
- package/dist/{isBigInt-bbW78ITJ.js → isBigInt-y7s3rsKc.js} +2 -2
- package/dist/{isBigInt-bbW78ITJ.js.map → isBigInt-y7s3rsKc.js.map} +1 -1
- package/dist/{isEmptyObject-D-fETD_f.cjs → isEmptyObject-BsHngDz4.cjs} +3 -3
- package/dist/{isEmptyObject-D-fETD_f.cjs.map → isEmptyObject-BsHngDz4.cjs.map} +1 -1
- package/dist/{isEmptyObject-CZsFdN7x.js → isEmptyObject-DPGR9iPj.js} +3 -3
- package/dist/{isEmptyObject-CZsFdN7x.js.map → isEmptyObject-DPGR9iPj.js.map} +1 -1
- package/dist/{isEmptyString-pmcf-orv.js → isEmptyString-BYMz_wt9.js} +3 -3
- package/dist/{isEmptyString-pmcf-orv.js.map → isEmptyString-BYMz_wt9.js.map} +1 -1
- package/dist/{isEmptyString-Dx6OM5PL.cjs → isEmptyString-C8PYNPgw.cjs} +3 -3
- package/dist/{isEmptyString-Dx6OM5PL.cjs.map → isEmptyString-C8PYNPgw.cjs.map} +1 -1
- package/dist/{isEmptyValue-v6BsHBiu.cjs → isEmptyValue-BXf7f1jz.cjs} +5 -5
- package/dist/{isEmptyValue-v6BsHBiu.cjs.map → isEmptyValue-BXf7f1jz.cjs.map} +1 -1
- package/dist/{isEmptyValue-CkiXENcT.js → isEmptyValue-D4OHTB3u.js} +5 -5
- package/dist/{isEmptyValue-CkiXENcT.js.map → isEmptyValue-D4OHTB3u.js.map} +1 -1
- package/dist/{isEqual-Dc8fNB2J.js → isEqual-DM4S_kWh.js} +4 -4
- package/dist/{isEqual-Dc8fNB2J.js.map → isEqual-DM4S_kWh.js.map} +1 -1
- package/dist/{isEqual-CZxetLzm.cjs → isEqual-DaPDxMyw.cjs} +4 -4
- package/dist/{isEqual-CZxetLzm.cjs.map → isEqual-DaPDxMyw.cjs.map} +1 -1
- package/dist/{isFinite-CI59vUHt.js → isFinite-BEJFOv6B.js} +3 -3
- package/dist/{isFinite-CI59vUHt.js.map → isFinite-BEJFOv6B.js.map} +1 -1
- package/dist/{isFinite-0z31xOa2.cjs → isFinite-DeDaBDr2.cjs} +3 -3
- package/dist/{isFinite-0z31xOa2.cjs.map → isFinite-DeDaBDr2.cjs.map} +1 -1
- package/dist/{isInteger-DUhd-dyt.cjs → isInteger-CQLThJOR.cjs} +2 -2
- package/dist/{isInteger-DUhd-dyt.cjs.map → isInteger-CQLThJOR.cjs.map} +1 -1
- package/dist/{isInteger-DeN5FIAr.js → isInteger-DEDbBGez.js} +2 -2
- package/dist/{isInteger-DeN5FIAr.js.map → isInteger-DEDbBGez.js.map} +1 -1
- package/dist/{isPlainObject-CjoJH9yk.d.ts → isPlainObject-BwTkj3G0.d.cts} +1 -1
- package/dist/{isPlainObject-DvxdHoAf.d.cts → isPlainObject-BwTkj3G0.d.ts} +1 -1
- package/dist/{isServer-TOmhgOtP.cjs → isServer-DmycqWsF.cjs} +2 -2
- package/dist/{isServer-TOmhgOtP.cjs.map → isServer-DmycqWsF.cjs.map} +1 -1
- package/dist/{isServer-BM5GzRpI.js → isServer-q3o6cSwD.js} +2 -2
- package/dist/{isServer-BM5GzRpI.js.map → isServer-q3o6cSwD.js.map} +1 -1
- package/dist/{isTypedArray-pAdBFUDl.cjs → isTypedArray-BQLbLXsU.cjs} +3 -3
- package/dist/{isTypedArray-pAdBFUDl.cjs.map → isTypedArray-BQLbLXsU.cjs.map} +1 -1
- package/dist/{isTypedArray-BPerK072.js → isTypedArray-XiBnifLN.js} +3 -3
- package/dist/{isTypedArray-BPerK072.js.map → isTypedArray-XiBnifLN.js.map} +1 -1
- package/dist/{isValidDomain-CHKOn79-.js → isValidDomain-B8Nukgw0.js} +5 -5
- package/dist/{isValidDomain-CHKOn79-.js.map → isValidDomain-B8Nukgw0.js.map} +1 -1
- package/dist/{isValidDomain-BMcr9vTp.cjs → isValidDomain-ZbyeGOO9.cjs} +5 -5
- package/dist/{isValidDomain-BMcr9vTp.cjs.map → isValidDomain-ZbyeGOO9.cjs.map} +1 -1
- package/dist/{noop-D4g9yTAW.cjs → noop-BY43WaoU.cjs} +2 -2
- package/dist/{noop-D4g9yTAW.cjs.map → noop-BY43WaoU.cjs.map} +1 -1
- package/dist/{noop-BaNz9ls5.js → noop-CjY8xVHv.js} +2 -2
- package/dist/{noop-BaNz9ls5.js.map → noop-CjY8xVHv.js.map} +1 -1
- package/dist/{normalizeSpaces-MWiYtSyS.cjs → normalizeSpaces-BhZp0U_6.cjs} +3 -3
- package/dist/{normalizeSpaces-MWiYtSyS.cjs.map → normalizeSpaces-BhZp0U_6.cjs.map} +1 -1
- package/dist/{normalizeSpaces-DupusmF5.js → normalizeSpaces-BoUDtq5P.js} +3 -3
- package/dist/{normalizeSpaces-DupusmF5.js.map → normalizeSpaces-BoUDtq5P.js.map} +1 -1
- package/dist/operations/index.cjs +7 -7
- package/dist/operations/index.cjs.map +1 -1
- package/dist/operations/index.d.cts +1 -1
- package/dist/operations/index.d.ts +1 -1
- package/dist/operations/index.js +7 -7
- package/dist/operations/index.js.map +1 -1
- package/dist/parsers/index.cjs +2 -2
- package/dist/parsers/index.d.cts +1 -1
- package/dist/parsers/index.d.ts +1 -1
- package/dist/parsers/index.js +2 -2
- package/dist/{parsers-Dl9fFra4.js → parsers-B8KYXIjE.js} +4 -4
- package/dist/{parsers-Dl9fFra4.js.map → parsers-B8KYXIjE.js.map} +1 -1
- package/dist/{parsers-Bd-YRt6j.cjs → parsers-B_FPX35n.cjs} +4 -4
- package/dist/{parsers-Bd-YRt6j.cjs.map → parsers-B_FPX35n.cjs.map} +1 -1
- package/dist/{parsing-CU_Mc7CF.cjs → parsing-BCZGco7n.cjs} +3 -3
- package/dist/{parsing-CU_Mc7CF.cjs.map → parsing-BCZGco7n.cjs.map} +1 -1
- package/dist/{parsing-BG73HUrI.js → parsing-Bfaw85Hd.js} +3 -3
- package/dist/{parsing-BG73HUrI.js.map → parsing-Bfaw85Hd.js.map} +1 -1
- package/dist/predicates/index.cjs +14 -14
- package/dist/predicates/index.d.cts +3 -3
- package/dist/predicates/index.d.ts +3 -3
- package/dist/predicates/index.js +14 -14
- package/dist/{predicates-Bd4AnXr0.cjs → predicates-8y28VrbT.cjs} +11 -11
- package/dist/{predicates-Bd4AnXr0.cjs.map → predicates-8y28VrbT.cjs.map} +1 -1
- package/dist/{predicates-VJN-VDha.js → predicates-KlyOvBSC.js} +11 -11
- package/dist/{predicates-VJN-VDha.js.map → predicates-KlyOvBSC.js.map} +1 -1
- package/dist/promises/index.cjs +4 -4
- package/dist/promises/index.cjs.map +1 -1
- package/dist/promises/index.d.cts +1 -1
- package/dist/promises/index.d.ts +1 -1
- package/dist/promises/index.js +4 -4
- package/dist/promises/index.js.map +1 -1
- package/dist/{punyCode-5wmummgP.cjs → punyCode-DnKi0qjS.cjs} +6 -6
- package/dist/{punyCode-5wmummgP.cjs.map → punyCode-DnKi0qjS.cjs.map} +1 -1
- package/dist/{punyCode-C0ft9dER.js → punyCode-Dwto1RpA.js} +6 -6
- package/dist/{punyCode-C0ft9dER.js.map → punyCode-Dwto1RpA.js.map} +1 -1
- package/dist/{removeSpaces-DpiJ1H1P.js → removeSpaces--8NW-HSx.js} +3 -3
- package/dist/{removeSpaces-DpiJ1H1P.js.map → removeSpaces--8NW-HSx.js.map} +1 -1
- package/dist/{removeSpaces-CPj1ABLa.cjs → removeSpaces-CmrrkeXz.cjs} +3 -3
- package/dist/{removeSpaces-CPj1ABLa.cjs.map → removeSpaces-CmrrkeXz.cjs.map} +1 -1
- package/dist/rzl-utils.global.js +13 -13
- package/dist/{safeJsonParse-BxOZgGy7.js → safeJsonParse-OnUwG2El.js} +6 -6
- package/dist/{safeJsonParse-BxOZgGy7.js.map → safeJsonParse-OnUwG2El.js.map} +1 -1
- package/dist/{safeJsonParse-v7ll9iFG.cjs → safeJsonParse-sFqVXf-e.cjs} +6 -6
- package/dist/{safeJsonParse-v7ll9iFG.cjs.map → safeJsonParse-sFqVXf-e.cjs.map} +1 -1
- package/dist/{safeStableStringify-C5Gc3ZED.js → safeStableStringify-B2KTTS3r.js} +4 -4
- package/dist/{safeStableStringify-C5Gc3ZED.js.map → safeStableStringify-B2KTTS3r.js.map} +1 -1
- package/dist/{safeStableStringify-BiUOLBYo.cjs → safeStableStringify-Cmi6GyWj.cjs} +4 -4
- package/dist/{safeStableStringify-BiUOLBYo.cjs.map → safeStableStringify-Cmi6GyWj.cjs.map} +1 -1
- package/dist/strings/index.cjs +5 -5
- package/dist/strings/index.cjs.map +1 -1
- package/dist/strings/index.d.cts +2 -2
- package/dist/strings/index.d.ts +2 -2
- package/dist/strings/index.js +5 -5
- package/dist/strings/index.js.map +1 -1
- package/dist/tailwind/index.cjs +2 -2
- package/dist/tailwind/index.d.cts +2 -2
- package/dist/tailwind/index.d.ts +2 -2
- package/dist/tailwind/index.js +2 -2
- package/dist/{tailwind-CxI2DXpR.js → tailwind-CUdmv-oO.js} +5 -5
- package/dist/{tailwind-CxI2DXpR.js.map → tailwind-CUdmv-oO.js.map} +1 -1
- package/dist/{tailwind-DhKiKZAc.cjs → tailwind-DUuboq52.cjs} +5 -5
- package/dist/{tailwind-DhKiKZAc.cjs.map → tailwind-DUuboq52.cjs.map} +1 -1
- package/dist/{toStringArrayUnRecursive-BaZrCGaR.js → toStringArrayUnRecursive-OOHGazks.js} +6 -6
- package/dist/{toStringArrayUnRecursive-BaZrCGaR.js.map → toStringArrayUnRecursive-OOHGazks.js.map} +1 -1
- package/dist/{toStringArrayUnRecursive-BuRBWRcB.cjs → toStringArrayUnRecursive-pfk2oP8C.cjs} +6 -6
- package/dist/{toStringArrayUnRecursive-BuRBWRcB.cjs.map → toStringArrayUnRecursive-pfk2oP8C.cjs.map} +1 -1
- package/dist/urls/index.cjs +3 -3
- package/dist/urls/index.d.cts +1 -1
- package/dist/urls/index.d.ts +1 -1
- package/dist/urls/index.js +3 -3
- package/dist/{urls-CyhKg1Cn.cjs → urls-BL9C_yU3.cjs} +11 -11
- package/dist/{urls-CyhKg1Cn.cjs.map → urls-BL9C_yU3.cjs.map} +1 -1
- package/dist/{urls-nr2hUK75.js → urls-BXT4Krsq.js} +11 -11
- package/dist/{urls-nr2hUK75.js.map → urls-BXT4Krsq.js.map} +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"punyCode-5wmummgP.cjs","names":["getPreciseType"],"sources":["../src/urls/utils/punyCode.ts"],"sourcesContent":["/** ---------------------------------------------------------\n * * ***Constants for `Punycode-UtilsJS` algorithm.***\n * ---------------------------------------------------------\n * These constants are used internally for encoding and decoding.\n *\n * Unicode domain names to ASCII (`Punycode-UtilsJS`) and vice versa.\n */\n\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\n\n/**\n * Constant `maxInt` for validate.\n */\nconst maxInt = 2147483647;\n\n/**\n * Bootstring parameters for `Punycode-UtilsJS`.\n */\nconst base = 36,\n tMin = 1,\n tMax = 26,\n skew = 38,\n damp = 700;\n\n/**\n * Initial bias and code point.\n */\nconst initialBias = 72,\n initialN = 128,\n delimiter = \"-\";\n\n/**\n * Regular expressions used internally.\n * Matches `Punycode-UtilsJS` prefix.\n */\nconst regexPunycode = /^xn--/;\n/**\n * Regular expressions used internally.\n * Matches non-ASCII chars.\n */\nconst regexNonASCII = /[^\\0-\\x7F]/;\n/**\n * Regular expressions used internally.\n * Matches domain label separators.\n */\nconst regexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g;\n\n/**\n * Error messages used internally.\n */\nconst errors: Record<string, string> = {\n overflow: \"Overflow: input needs wider integers to process\",\n \"not-basic\": \"Illegal input >= 0x80 (not a basic code point)\",\n \"invalid-input\": \"Invalid input\"\n};\n\n/**\n * Aliases of `Math.floor`.\n */\nconst floor = Math.floor;\n/** \n * Aliases of `String.fromCharCode`.\n\n*/\nconst stringFromCharCode = String.fromCharCode;\n\n/** ---------------------------------------------------------\n * * ***Throws a RangeError with a predefined error message.***\n * ---------------------------------------------------------\n *\n * @param type - Key of the error type to throw.\n */\nfunction error(type: keyof typeof errors): never {\n throw new RangeError(errors[type]);\n}\n\n/** ---------------------------------------------------------\n * * ***Maps an array using a callback function.***\n * ---------------------------------------------------------\n *\n * @param array - Array to transform.\n * @param fn - Function to apply to each element.\n * @returns Transformed array.\n */\nfunction map<T, U>(array: T[], fn: (v: T) => U): U[] {\n const result: U[] = [];\n let length = array.length;\n while (length--) {\n if (array[length]) {\n result[length] = fn(array[length]!);\n }\n }\n return result;\n}\n\n/** ---------------------------------------------------------\n * * ***Maps a domain name using a callback on each label.***\n * ---------------------------------------------------------\n *\n * Handles email-like domains (local@domain).\n * @param domain - Domain string to process.\n * @param fn - Function applied to each domain label.\n * @returns Transformed domain string.\n */\nfunction mapDomain(domain: string, fn: (v: string) => string): string {\n const parts = domain.split(\"@\");\n let result = \"\";\n if (parts.length > 1) {\n result = parts[0] + \"@\";\n if (parts[1]) domain = parts[1];\n }\n domain = domain.replace(regexSeparators, \"\\x2E\");\n const labels = domain.split(\".\");\n return result + map(labels, fn).join(\".\");\n}\n\n/** ---------------------------------------------------------\n * * ***Converts a UCS-2 encoded string to an array of Unicode code points.***\n * ---------------------------------------------------------\n *\n * @param input - String to decode.\n * @returns Array of Unicode code points.\n */\nfunction ucs2decode(input: string): number[] {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.ucs2.decode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const output: number[] = [];\n let counter = 0;\n const length = input.length;\n while (counter < length) {\n const value = input.charCodeAt(counter++);\n if (value >= 0xd800 && value <= 0xdbff && counter < length) {\n const extra = input.charCodeAt(counter++);\n if ((extra & 0xfc00) === 0xdc00)\n output.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);\n else {\n output.push(value);\n counter--;\n }\n } else output.push(value);\n }\n return output;\n}\n\n/** ---------------------------------------------------------\n * * ***Encodes an array of Unicode code points to a string.***\n * ---------------------------------------------------------\n *\n * @param points - Array of Unicode code points.\n * @returns Encoded string.\n */\nconst ucs2encode = (points: number[]): string => {\n if (\n !Array.isArray(points) ||\n !points.every((p) => typeof p === \"number\" && Number.isFinite(p))\n ) {\n throw new TypeError(\n `Utils \\`punycodeUtilsJS.ucs2.encode\\`, parameter \\`points\\` must be an array of numbers, but received: \\`${getPreciseType(\n points\n )}\\`.`\n );\n }\n\n return String.fromCodePoint(...points);\n};\n\n/** ---------------------------------------------------------\n * * ***Converts a basic code point to its digit value for `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param codePoint - Unicode code point.\n * @returns Digit value.\n */\nfunction basicToDigit(codePoint: number): number {\n if (codePoint >= 0x30 && codePoint < 0x3a) return 26 + (codePoint - 0x30);\n if (codePoint >= 0x41 && codePoint < 0x5b) return codePoint - 0x41;\n if (codePoint >= 0x61 && codePoint < 0x7b) return codePoint - 0x61;\n return base;\n}\n\n/** ---------------------------------------------------------\n * * ***Converts a digit to a basic code point for `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param digit - Numeric value.\n * @param flag - Bias flag (0 or 1).\n * @returns Code point.\n */\nfunction digitToBasic(digit: number, flag: number): number {\n return digit + 22 + 75 * (digit < 26 ? 1 : 0) - Number(flag !== 0) * 32;\n}\n\n/** ---------------------------------------------------------\n * * ***Bias adaptation function for `Punycode-UtilsJS` encoding/decoding.***\n * ---------------------------------------------------------\n *\n * @param delta - Delta value.\n * @param numPoints - Number of code points.\n * @param firstTime - Indicates first adaptation.\n * @returns Adapted bias.\n */\nfunction adapt(delta: number, numPoints: number, firstTime: boolean): number {\n let k = 0;\n delta = firstTime ? floor(delta / damp) : delta >> 1;\n delta += floor(delta / numPoints);\n while (delta > ((base - tMin) * tMax) >> 1) {\n delta = floor(delta / (base - tMin));\n k += base;\n }\n return floor(k + ((base - tMin + 1) * delta) / (delta + skew));\n}\n\n/** ---------------------------------------------------------\n * * ***Decodes a `Punycode-UtilsJS` string to Unicode.***\n * ---------------------------------------------------------\n *\n * @param input - `Punycode-UtilsJS` string.\n * @returns Decoded Unicode string.\n */\nfunction decode(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.decode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const output: number[] = [];\n const inputLength = input.length;\n let i = 0,\n n = initialN,\n bias = initialBias;\n\n let basic = input.lastIndexOf(delimiter);\n if (basic < 0) basic = 0;\n\n for (let j = 0; j < basic; j++) {\n if (input.charCodeAt(j) >= 0x80) error(\"not-basic\");\n output.push(input.charCodeAt(j));\n }\n\n for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {\n const oldi = i;\n let w = 1;\n for (let k = base; ; k += base) {\n if (index >= inputLength) error(\"invalid-input\");\n const digit = basicToDigit(input.charCodeAt(index++));\n if (digit >= base) error(\"invalid-input\");\n if (digit > floor((maxInt - i) / w)) error(\"overflow\");\n i += digit * w;\n const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n if (digit < t) break;\n const baseMinusT = base - t;\n if (w > floor(maxInt / baseMinusT)) error(\"overflow\");\n w *= baseMinusT;\n }\n const out = output.length + 1;\n bias = adapt(i - oldi, out, oldi === 0);\n if (floor(i / out) > maxInt - n) error(\"overflow\");\n n += floor(i / out);\n i %= out;\n output.splice(i++, 0, n);\n }\n return String.fromCodePoint(...output);\n}\n\n/** ---------------------------------------------------------\n * * ***Encodes a Unicode string to `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param input - Unicode string.\n * @returns `Punycode-UtilsJS` string.\n */\nfunction encode(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.encode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const output: string[] = [];\n const points = ucs2decode(input);\n const inputLength = points.length;\n let n = initialN,\n delta = 0,\n bias = initialBias;\n\n for (const cp of points) if (cp < 0x80) output.push(stringFromCharCode(cp));\n const basicLength = output.length;\n let handledCPCount = basicLength;\n if (basicLength) output.push(delimiter);\n\n while (handledCPCount < inputLength) {\n let m = maxInt;\n for (const cp of points) if (cp >= n && cp < m) m = cp;\n\n const handledCPCountPlusOne = handledCPCount + 1;\n if (m - n > floor((maxInt - delta) / handledCPCountPlusOne))\n error(\"overflow\");\n delta += (m - n) * handledCPCountPlusOne;\n n = m;\n\n for (const cp of points) {\n if (cp < n) delta++;\n if (cp === n) {\n let q = delta;\n for (let k = base; ; k += base) {\n const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n if (q < t) break;\n output.push(\n stringFromCharCode(digitToBasic(t + ((q - t) % (base - t)), 0))\n );\n q = floor((q - t) / (base - t));\n }\n output.push(stringFromCharCode(digitToBasic(q, 0)));\n bias = adapt(\n delta,\n handledCPCountPlusOne,\n handledCPCount === basicLength\n );\n delta = 0;\n handledCPCount++;\n }\n }\n delta++;\n n++;\n }\n\n return output.join(\"\");\n}\n\n/** ---------------------------------------------------------\n * * ***Converts `Punycode-UtilsJS` to Unicode for domain names.***\n * ---------------------------------------------------------\n *\n * @param input - Domain or label.\n * @returns Unicode string.\n */\nfunction toUnicode(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.toUnicode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n return mapDomain(input, (str) =>\n regexPunycode.test(str) ? decode(str.slice(4).toLowerCase()) : str\n );\n}\n\n/** ---------------------------------------------------------\n * * ***Converts Unicode to ASCII (`Punycode-UtilsJS`) for domain names.***\n * ---------------------------------------------------------\n *\n * @param input - Domain or label.\n * @returns ASCII string.\n */\nfunction toASCII(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.toASCII\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n return mapDomain(input, (str) =>\n regexNonASCII.test(str) ? \"xn--\" + encode(str) : str\n );\n}\n\ntype PunycodeUtilsJS = {\n /** ---------------------------------------------------------\n * * ***Version of the `Punycode-UtilsJS` implementation.***\n * ---------------------------------------------------------\n *\n * @example\n * console.log(punycodeUtilsJS.version); // \"1.0.0\"\n */\n version: string;\n /** ---------------------------------------------------------\n * * ***UCS-2 utility functions.***\n * ---------------------------------------------------------\n */\n ucs2: {\n /** ---------------------------------------------------------\n * * ***Decodes a UCS-2 encoded string to an array of Unicode code points.***\n * ---------------------------------------------------------\n *\n * @param input - The UCS-2 string to decode.\n * @returns Array of Unicode code points.\n * @example\n * punycodeUtilsJS.ucs2.decode(\"𐍈\");\n * // ➔ [66376]\n */\n decode: (input: string) => number[];\n /** ---------------------------------------------------------\n * * ***Encodes an array of Unicode code points to a UCS-2 string.***\n * ---------------------------------------------------------\n *\n * @param points - Array of Unicode code points.\n * @returns Encoded string.\n * @example\n * punycodeUtilsJS.ucs2.encode([66376]);\n * // ➔ \"𐍈\"\n */\n encode: (points: number[]) => string;\n };\n /** ---------------------------------------------------------\n * * ***Decodes a `Punycode-UtilsJS` string to a Unicode string.***\n * ---------------------------------------------------------\n *\n * @param input - The `Punycode-UtilsJS` string to decode.\n * @returns Decoded Unicode string.\n * @example\n * punycodeUtilsJS.decode(\"xn--fsq\");\n * // ➔ \"ü\"\n */\n decode: (input: string) => string;\n /** ---------------------------------------------------------\n * * ***Encodes a Unicode string to `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param input - Unicode string to encode.\n * @returns `Punycode-UtilsJS` string.\n * @example\n * punycodeUtilsJS.encode(\"ü\");\n * // ➔ \"xn--fsq\"\n */\n encode: (input: string) => string;\n /** ---------------------------------------------------------\n * * ***Converts a Unicode domain or label to ASCII (`Punycode-UtilsJS`).***\n * ---------------------------------------------------------\n *\n * @param input - Domain or label string.\n * @returns ASCII string suitable for DNS.\n * @example\n * punycodeUtilsJS.toASCII(\"пример.рф\");\n * // ➔ \"xn--e1afmkfd.xn--p1ai\"\n */\n toASCII: (input: string) => string;\n /** ---------------------------------------------------------\n * * ***Converts an ASCII (`Punycode-UtilsJS`) domain or label to Unicode.***\n * ---------------------------------------------------------\n *\n * @param input - ASCII string (with xn-- prefix if needed).\n * @returns Unicode string.\n * @example\n * punycodeUtilsJS.toUnicode(\"xn--e1afmkfd.xn--p1ai\");\n * // ➔ \"пример.рф\"\n */\n toUnicode: (input: string) => string;\n};\n\n/** ---------------------------------------------------------\n * * ***`Punycode-UtilsJS` object exposing all API functions and version.***\n * ---------------------------------------------------------\n * Provides encoding and decoding of Unicode domain names to ASCII (`Punycode-UtilsJS`)\n * and vice versa.\n *\n * - Useful for IDN (Internationalized Domain Names) support.\n */\nconst punycodeUtilsJS: PunycodeUtilsJS = {\n version: \"1.0.0\",\n ucs2: {\n decode: ucs2decode,\n encode: ucs2encode\n },\n decode: decode,\n encode: encode,\n toASCII: toASCII,\n toUnicode: toUnicode\n};\n\n/**\n * Export individual functions.\n */\nexport { punycodeUtilsJS };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,SAAS;;;;AAKf,MAAM,OAAO,IACX,OAAO,GACP,OAAO,IACP,OAAO,IACP,OAAO;;;;AAKT,MAAM,cAAc,IAClB,WAAW,KAC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C3H,CAAC;CAEF,OAAO,UAAU,QAAQ,QACvB,cAAc,KAAK,IAAI,GAAG,SAAS,OAAO,IAAI,GAAG,IAClD;;;;;;;;;;AA8FH,MAAM,kBAAmC;CACvC,SAAS;CACT,MAAM;EACJ,QAAQ;EACR,QAAQ;EACT;CACO;CACA;CACC;CACE;CACZ"}
|
|
1
|
+
{"version":3,"file":"punyCode-DnKi0qjS.cjs","names":["getPreciseType"],"sources":["../src/urls/utils/punyCode.ts"],"sourcesContent":["/** ---------------------------------------------------------\n * * ***Constants for `Punycode-UtilsJS` algorithm.***\n * ---------------------------------------------------------\n * These constants are used internally for encoding and decoding.\n *\n * Unicode domain names to ASCII (`Punycode-UtilsJS`) and vice versa.\n */\n\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\n\n/**\n * Constant `maxInt` for validate.\n */\nconst maxInt = 2147483647;\n\n/**\n * Bootstring parameters for `Punycode-UtilsJS`.\n */\nconst base = 36,\n tMin = 1,\n tMax = 26,\n skew = 38,\n damp = 700;\n\n/**\n * Initial bias and code point.\n */\nconst initialBias = 72,\n initialN = 128,\n delimiter = \"-\";\n\n/**\n * Regular expressions used internally.\n * Matches `Punycode-UtilsJS` prefix.\n */\nconst regexPunycode = /^xn--/;\n/**\n * Regular expressions used internally.\n * Matches non-ASCII chars.\n */\nconst regexNonASCII = /[^\\0-\\x7F]/;\n/**\n * Regular expressions used internally.\n * Matches domain label separators.\n */\nconst regexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g;\n\n/**\n * Error messages used internally.\n */\nconst errors: Record<string, string> = {\n overflow: \"Overflow: input needs wider integers to process\",\n \"not-basic\": \"Illegal input >= 0x80 (not a basic code point)\",\n \"invalid-input\": \"Invalid input\"\n};\n\n/**\n * Aliases of `Math.floor`.\n */\nconst floor = Math.floor;\n/** \n * Aliases of `String.fromCharCode`.\n\n*/\nconst stringFromCharCode = String.fromCharCode;\n\n/** ---------------------------------------------------------\n * * ***Throws a RangeError with a predefined error message.***\n * ---------------------------------------------------------\n *\n * @param type - Key of the error type to throw.\n */\nfunction error(type: keyof typeof errors): never {\n throw new RangeError(errors[type]);\n}\n\n/** ---------------------------------------------------------\n * * ***Maps an array using a callback function.***\n * ---------------------------------------------------------\n *\n * @param array - Array to transform.\n * @param fn - Function to apply to each element.\n * @returns Transformed array.\n */\nfunction map<T, U>(array: T[], fn: (v: T) => U): U[] {\n const result: U[] = [];\n let length = array.length;\n while (length--) {\n if (array[length]) {\n result[length] = fn(array[length]!);\n }\n }\n return result;\n}\n\n/** ---------------------------------------------------------\n * * ***Maps a domain name using a callback on each label.***\n * ---------------------------------------------------------\n *\n * Handles email-like domains (local@domain).\n * @param domain - Domain string to process.\n * @param fn - Function applied to each domain label.\n * @returns Transformed domain string.\n */\nfunction mapDomain(domain: string, fn: (v: string) => string): string {\n const parts = domain.split(\"@\");\n let result = \"\";\n if (parts.length > 1) {\n result = parts[0] + \"@\";\n if (parts[1]) domain = parts[1];\n }\n domain = domain.replace(regexSeparators, \"\\x2E\");\n const labels = domain.split(\".\");\n return result + map(labels, fn).join(\".\");\n}\n\n/** ---------------------------------------------------------\n * * ***Converts a UCS-2 encoded string to an array of Unicode code points.***\n * ---------------------------------------------------------\n *\n * @param input - String to decode.\n * @returns Array of Unicode code points.\n */\nfunction ucs2decode(input: string): number[] {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.ucs2.decode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const output: number[] = [];\n let counter = 0;\n const length = input.length;\n while (counter < length) {\n const value = input.charCodeAt(counter++);\n if (value >= 0xd800 && value <= 0xdbff && counter < length) {\n const extra = input.charCodeAt(counter++);\n if ((extra & 0xfc00) === 0xdc00)\n output.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);\n else {\n output.push(value);\n counter--;\n }\n } else output.push(value);\n }\n return output;\n}\n\n/** ---------------------------------------------------------\n * * ***Encodes an array of Unicode code points to a string.***\n * ---------------------------------------------------------\n *\n * @param points - Array of Unicode code points.\n * @returns Encoded string.\n */\nconst ucs2encode = (points: number[]): string => {\n if (\n !Array.isArray(points) ||\n !points.every((p) => typeof p === \"number\" && Number.isFinite(p))\n ) {\n throw new TypeError(\n `Utils \\`punycodeUtilsJS.ucs2.encode\\`, parameter \\`points\\` must be an array of numbers, but received: \\`${getPreciseType(\n points\n )}\\`.`\n );\n }\n\n return String.fromCodePoint(...points);\n};\n\n/** ---------------------------------------------------------\n * * ***Converts a basic code point to its digit value for `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param codePoint - Unicode code point.\n * @returns Digit value.\n */\nfunction basicToDigit(codePoint: number): number {\n if (codePoint >= 0x30 && codePoint < 0x3a) return 26 + (codePoint - 0x30);\n if (codePoint >= 0x41 && codePoint < 0x5b) return codePoint - 0x41;\n if (codePoint >= 0x61 && codePoint < 0x7b) return codePoint - 0x61;\n return base;\n}\n\n/** ---------------------------------------------------------\n * * ***Converts a digit to a basic code point for `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param digit - Numeric value.\n * @param flag - Bias flag (0 or 1).\n * @returns Code point.\n */\nfunction digitToBasic(digit: number, flag: number): number {\n return digit + 22 + 75 * (digit < 26 ? 1 : 0) - Number(flag !== 0) * 32;\n}\n\n/** ---------------------------------------------------------\n * * ***Bias adaptation function for `Punycode-UtilsJS` encoding/decoding.***\n * ---------------------------------------------------------\n *\n * @param delta - Delta value.\n * @param numPoints - Number of code points.\n * @param firstTime - Indicates first adaptation.\n * @returns Adapted bias.\n */\nfunction adapt(delta: number, numPoints: number, firstTime: boolean): number {\n let k = 0;\n delta = firstTime ? floor(delta / damp) : delta >> 1;\n delta += floor(delta / numPoints);\n while (delta > ((base - tMin) * tMax) >> 1) {\n delta = floor(delta / (base - tMin));\n k += base;\n }\n return floor(k + ((base - tMin + 1) * delta) / (delta + skew));\n}\n\n/** ---------------------------------------------------------\n * * ***Decodes a `Punycode-UtilsJS` string to Unicode.***\n * ---------------------------------------------------------\n *\n * @param input - `Punycode-UtilsJS` string.\n * @returns Decoded Unicode string.\n */\nfunction decode(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.decode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const output: number[] = [];\n const inputLength = input.length;\n let i = 0,\n n = initialN,\n bias = initialBias;\n\n let basic = input.lastIndexOf(delimiter);\n if (basic < 0) basic = 0;\n\n for (let j = 0; j < basic; j++) {\n if (input.charCodeAt(j) >= 0x80) error(\"not-basic\");\n output.push(input.charCodeAt(j));\n }\n\n for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {\n const oldi = i;\n let w = 1;\n for (let k = base; ; k += base) {\n if (index >= inputLength) error(\"invalid-input\");\n const digit = basicToDigit(input.charCodeAt(index++));\n if (digit >= base) error(\"invalid-input\");\n if (digit > floor((maxInt - i) / w)) error(\"overflow\");\n i += digit * w;\n const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n if (digit < t) break;\n const baseMinusT = base - t;\n if (w > floor(maxInt / baseMinusT)) error(\"overflow\");\n w *= baseMinusT;\n }\n const out = output.length + 1;\n bias = adapt(i - oldi, out, oldi === 0);\n if (floor(i / out) > maxInt - n) error(\"overflow\");\n n += floor(i / out);\n i %= out;\n output.splice(i++, 0, n);\n }\n return String.fromCodePoint(...output);\n}\n\n/** ---------------------------------------------------------\n * * ***Encodes a Unicode string to `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param input - Unicode string.\n * @returns `Punycode-UtilsJS` string.\n */\nfunction encode(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.encode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const output: string[] = [];\n const points = ucs2decode(input);\n const inputLength = points.length;\n let n = initialN,\n delta = 0,\n bias = initialBias;\n\n for (const cp of points) if (cp < 0x80) output.push(stringFromCharCode(cp));\n const basicLength = output.length;\n let handledCPCount = basicLength;\n if (basicLength) output.push(delimiter);\n\n while (handledCPCount < inputLength) {\n let m = maxInt;\n for (const cp of points) if (cp >= n && cp < m) m = cp;\n\n const handledCPCountPlusOne = handledCPCount + 1;\n if (m - n > floor((maxInt - delta) / handledCPCountPlusOne))\n error(\"overflow\");\n delta += (m - n) * handledCPCountPlusOne;\n n = m;\n\n for (const cp of points) {\n if (cp < n) delta++;\n if (cp === n) {\n let q = delta;\n for (let k = base; ; k += base) {\n const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n if (q < t) break;\n output.push(\n stringFromCharCode(digitToBasic(t + ((q - t) % (base - t)), 0))\n );\n q = floor((q - t) / (base - t));\n }\n output.push(stringFromCharCode(digitToBasic(q, 0)));\n bias = adapt(\n delta,\n handledCPCountPlusOne,\n handledCPCount === basicLength\n );\n delta = 0;\n handledCPCount++;\n }\n }\n delta++;\n n++;\n }\n\n return output.join(\"\");\n}\n\n/** ---------------------------------------------------------\n * * ***Converts `Punycode-UtilsJS` to Unicode for domain names.***\n * ---------------------------------------------------------\n *\n * @param input - Domain or label.\n * @returns Unicode string.\n */\nfunction toUnicode(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.toUnicode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n return mapDomain(input, (str) =>\n regexPunycode.test(str) ? decode(str.slice(4).toLowerCase()) : str\n );\n}\n\n/** ---------------------------------------------------------\n * * ***Converts Unicode to ASCII (`Punycode-UtilsJS`) for domain names.***\n * ---------------------------------------------------------\n *\n * @param input - Domain or label.\n * @returns ASCII string.\n */\nfunction toASCII(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.toASCII\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n return mapDomain(input, (str) =>\n regexNonASCII.test(str) ? \"xn--\" + encode(str) : str\n );\n}\n\ntype PunycodeUtilsJS = {\n /** ---------------------------------------------------------\n * * ***Version of the `Punycode-UtilsJS` implementation.***\n * ---------------------------------------------------------\n *\n * @example\n * console.log(punycodeUtilsJS.version); // \"1.0.0\"\n */\n version: string;\n /** ---------------------------------------------------------\n * * ***UCS-2 utility functions.***\n * ---------------------------------------------------------\n */\n ucs2: {\n /** ---------------------------------------------------------\n * * ***Decodes a UCS-2 encoded string to an array of Unicode code points.***\n * ---------------------------------------------------------\n *\n * @param input - The UCS-2 string to decode.\n * @returns Array of Unicode code points.\n * @example\n * punycodeUtilsJS.ucs2.decode(\"𐍈\");\n * // ➔ [66376]\n */\n decode: (input: string) => number[];\n /** ---------------------------------------------------------\n * * ***Encodes an array of Unicode code points to a UCS-2 string.***\n * ---------------------------------------------------------\n *\n * @param points - Array of Unicode code points.\n * @returns Encoded string.\n * @example\n * punycodeUtilsJS.ucs2.encode([66376]);\n * // ➔ \"𐍈\"\n */\n encode: (points: number[]) => string;\n };\n /** ---------------------------------------------------------\n * * ***Decodes a `Punycode-UtilsJS` string to a Unicode string.***\n * ---------------------------------------------------------\n *\n * @param input - The `Punycode-UtilsJS` string to decode.\n * @returns Decoded Unicode string.\n * @example\n * punycodeUtilsJS.decode(\"xn--fsq\");\n * // ➔ \"ü\"\n */\n decode: (input: string) => string;\n /** ---------------------------------------------------------\n * * ***Encodes a Unicode string to `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param input - Unicode string to encode.\n * @returns `Punycode-UtilsJS` string.\n * @example\n * punycodeUtilsJS.encode(\"ü\");\n * // ➔ \"xn--fsq\"\n */\n encode: (input: string) => string;\n /** ---------------------------------------------------------\n * * ***Converts a Unicode domain or label to ASCII (`Punycode-UtilsJS`).***\n * ---------------------------------------------------------\n *\n * @param input - Domain or label string.\n * @returns ASCII string suitable for DNS.\n * @example\n * punycodeUtilsJS.toASCII(\"пример.рф\");\n * // ➔ \"xn--e1afmkfd.xn--p1ai\"\n */\n toASCII: (input: string) => string;\n /** ---------------------------------------------------------\n * * ***Converts an ASCII (`Punycode-UtilsJS`) domain or label to Unicode.***\n * ---------------------------------------------------------\n *\n * @param input - ASCII string (with xn-- prefix if needed).\n * @returns Unicode string.\n * @example\n * punycodeUtilsJS.toUnicode(\"xn--e1afmkfd.xn--p1ai\");\n * // ➔ \"пример.рф\"\n */\n toUnicode: (input: string) => string;\n};\n\n/** ---------------------------------------------------------\n * * ***`Punycode-UtilsJS` object exposing all API functions and version.***\n * ---------------------------------------------------------\n * Provides encoding and decoding of Unicode domain names to ASCII (`Punycode-UtilsJS`)\n * and vice versa.\n *\n * - Useful for IDN (Internationalized Domain Names) support.\n */\nconst punycodeUtilsJS: PunycodeUtilsJS = {\n version: \"1.0.0\",\n ucs2: {\n decode: ucs2decode,\n encode: ucs2encode\n },\n decode: decode,\n encode: encode,\n toASCII: toASCII,\n toUnicode: toUnicode\n};\n\n/**\n * Export individual functions.\n */\nexport { punycodeUtilsJS };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,SAAS;;;;AAKf,MAAM,OAAO,IACX,OAAO,GACP,OAAO,IACP,OAAO,IACP,OAAO;;;;AAKT,MAAM,cAAc,IAClB,WAAW,KACX,YAAY;;;;;AAMd,MAAM,gBAAgB;;;;;AAKtB,MAAM,gBAAgB;;;;;AAKtB,MAAM,kBAAkB;;;;AAKxB,MAAM,SAAiC;CACrC,UAAU;CACV,aAAa;CACb,iBAAiB;AACnB;;;;AAKA,MAAM,QAAQ,KAAK;;;;;AAKnB,MAAM,qBAAqB,OAAO;;;;;;;AAQlC,SAAS,MAAM,MAAkC;CAC/C,MAAM,IAAI,WAAW,OAAO,KAAK;AACnC;;;;;;;;;AAUA,SAAS,IAAU,OAAY,IAAsB;CACnD,MAAM,SAAc,CAAC;CACrB,IAAI,SAAS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nB,IAAI;EAEJ,KAAK,MAAM,MAAM,QAAQ;GACvB,IAAI,KAAK,GAAG;GACZ,IAAI,OAAO,GAAG;IACZ,IAAI,IAAI;IACR,KAAK,IAAI,IAAI,OAAQ,KAAK,MAAM;KAC9B,MAAM,IAAI,KAAK,OAAO,OAAO,KAAK,OAAO,OAAO,OAAO,IAAI;KAC3D,IAAI,IAAI,GAAG;KACX,OAAO,KACL,mBAAmB,aAAa,KAAM,IAAI,MAAM,OAAO,IAAK,CAAC,CAAC,CAChE;KACA,IAAI,OAAO,IAAI,MAAM,OAAO,EAAE;IAChC;IACA,OAAO,KAAK,mBAAmB,aAAa,GAAG,CAAC,CAAC,CAAC;IAClD,OAAO,MACL,OACA,uBACA,mBAAmB,WACrB;IACA,QAAQ;IACR;GACF;EACF;EACA;EACA;CACF;CAEA,OAAO,OAAO,KAAK,EAAE;AACvB;;;;;;;;AASA,SAAS,UAAU,OAAuB;CACxC,sCAAe,OAAO,EACpB,UAAU,EAAE,aAAa,gBACvB,8EAA8E,UAAU,sBAAsB,YAAY,KAC9H,CAAC;CAED,OAAO,UAAU,QAAQ,QACvB,cAAc,KAAK,GAAG,IAAI,OAAO,IAAI,MAAM,CAAC,EAAE,YAAY,CAAC,IAAI,GACjE;AACF;;;;;;;;AASA,SAAS,QAAQ,OAAuB;CACtC,sCAAe,OAAO,EACpB,UAAU,EAAE,aAAa,gBACvB,4EAA4E,UAAU,sBAAsB,YAAY,KAC5H,CAAC;CAED,OAAO,UAAU,QAAQ,QACvB,cAAc,KAAK,GAAG,IAAI,SAAS,OAAO,GAAG,IAAI,GACnD;AACF;;;;;;;;;AA6FA,MAAM,kBAAmC;CACvC,SAAS;CACT,MAAM;EACJ,QAAQ;EACR,QAAQ;CACV;CACQ;CACA;CACC;CACE;AACb"}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.13.
|
|
5
|
+
* Version: `3.13.1`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
|
-
import { r as getPreciseType } from "./assertIsBoolean-
|
|
11
|
-
import { t as assertIsString } from "./assertIsString-
|
|
10
|
+
import { r as getPreciseType } from "./assertIsBoolean-CWUs-I5l.js";
|
|
11
|
+
import { t as assertIsString } from "./assertIsString-CY_WkCLr.js";
|
|
12
12
|
const maxInt = 2147483647;
|
|
13
13
|
const base = 36, tMin = 1, tMax = 26, skew = 38, damp = 700;
|
|
14
14
|
const initialBias = 72, initialN = 128, delimiter = "-";
|
|
@@ -77,11 +77,11 @@ function adapt(delta, numPoints, firstTime) {
|
|
|
77
77
|
let k = 0;
|
|
78
78
|
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
79
79
|
delta += floor(delta / numPoints);
|
|
80
|
-
while (delta >
|
|
80
|
+
while (delta > 455) {
|
|
81
81
|
delta = floor(delta / (base - tMin));
|
|
82
82
|
k += base;
|
|
83
83
|
}
|
|
84
|
-
return floor(k +
|
|
84
|
+
return floor(k + 36 * delta / (delta + skew));
|
|
85
85
|
}
|
|
86
86
|
function decode(input) {
|
|
87
87
|
assertIsString(input, { message: ({ currentType, validType }) => `Utils \`punycodeUtilsJS.decode\`, parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.` });
|
|
@@ -176,4 +176,4 @@ const punycodeUtilsJS = {
|
|
|
176
176
|
toUnicode
|
|
177
177
|
};
|
|
178
178
|
export { punycodeUtilsJS as t };
|
|
179
|
-
//# sourceMappingURL=punyCode-
|
|
179
|
+
//# sourceMappingURL=punyCode-Dwto1RpA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"punyCode-C0ft9dER.js","names":[],"sources":["../src/urls/utils/punyCode.ts"],"sourcesContent":["/** ---------------------------------------------------------\n * * ***Constants for `Punycode-UtilsJS` algorithm.***\n * ---------------------------------------------------------\n * These constants are used internally for encoding and decoding.\n *\n * Unicode domain names to ASCII (`Punycode-UtilsJS`) and vice versa.\n */\n\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\n\n/**\n * Constant `maxInt` for validate.\n */\nconst maxInt = 2147483647;\n\n/**\n * Bootstring parameters for `Punycode-UtilsJS`.\n */\nconst base = 36,\n tMin = 1,\n tMax = 26,\n skew = 38,\n damp = 700;\n\n/**\n * Initial bias and code point.\n */\nconst initialBias = 72,\n initialN = 128,\n delimiter = \"-\";\n\n/**\n * Regular expressions used internally.\n * Matches `Punycode-UtilsJS` prefix.\n */\nconst regexPunycode = /^xn--/;\n/**\n * Regular expressions used internally.\n * Matches non-ASCII chars.\n */\nconst regexNonASCII = /[^\\0-\\x7F]/;\n/**\n * Regular expressions used internally.\n * Matches domain label separators.\n */\nconst regexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g;\n\n/**\n * Error messages used internally.\n */\nconst errors: Record<string, string> = {\n overflow: \"Overflow: input needs wider integers to process\",\n \"not-basic\": \"Illegal input >= 0x80 (not a basic code point)\",\n \"invalid-input\": \"Invalid input\"\n};\n\n/**\n * Aliases of `Math.floor`.\n */\nconst floor = Math.floor;\n/** \n * Aliases of `String.fromCharCode`.\n\n*/\nconst stringFromCharCode = String.fromCharCode;\n\n/** ---------------------------------------------------------\n * * ***Throws a RangeError with a predefined error message.***\n * ---------------------------------------------------------\n *\n * @param type - Key of the error type to throw.\n */\nfunction error(type: keyof typeof errors): never {\n throw new RangeError(errors[type]);\n}\n\n/** ---------------------------------------------------------\n * * ***Maps an array using a callback function.***\n * ---------------------------------------------------------\n *\n * @param array - Array to transform.\n * @param fn - Function to apply to each element.\n * @returns Transformed array.\n */\nfunction map<T, U>(array: T[], fn: (v: T) => U): U[] {\n const result: U[] = [];\n let length = array.length;\n while (length--) {\n if (array[length]) {\n result[length] = fn(array[length]!);\n }\n }\n return result;\n}\n\n/** ---------------------------------------------------------\n * * ***Maps a domain name using a callback on each label.***\n * ---------------------------------------------------------\n *\n * Handles email-like domains (local@domain).\n * @param domain - Domain string to process.\n * @param fn - Function applied to each domain label.\n * @returns Transformed domain string.\n */\nfunction mapDomain(domain: string, fn: (v: string) => string): string {\n const parts = domain.split(\"@\");\n let result = \"\";\n if (parts.length > 1) {\n result = parts[0] + \"@\";\n if (parts[1]) domain = parts[1];\n }\n domain = domain.replace(regexSeparators, \"\\x2E\");\n const labels = domain.split(\".\");\n return result + map(labels, fn).join(\".\");\n}\n\n/** ---------------------------------------------------------\n * * ***Converts a UCS-2 encoded string to an array of Unicode code points.***\n * ---------------------------------------------------------\n *\n * @param input - String to decode.\n * @returns Array of Unicode code points.\n */\nfunction ucs2decode(input: string): number[] {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.ucs2.decode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const output: number[] = [];\n let counter = 0;\n const length = input.length;\n while (counter < length) {\n const value = input.charCodeAt(counter++);\n if (value >= 0xd800 && value <= 0xdbff && counter < length) {\n const extra = input.charCodeAt(counter++);\n if ((extra & 0xfc00) === 0xdc00)\n output.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);\n else {\n output.push(value);\n counter--;\n }\n } else output.push(value);\n }\n return output;\n}\n\n/** ---------------------------------------------------------\n * * ***Encodes an array of Unicode code points to a string.***\n * ---------------------------------------------------------\n *\n * @param points - Array of Unicode code points.\n * @returns Encoded string.\n */\nconst ucs2encode = (points: number[]): string => {\n if (\n !Array.isArray(points) ||\n !points.every((p) => typeof p === \"number\" && Number.isFinite(p))\n ) {\n throw new TypeError(\n `Utils \\`punycodeUtilsJS.ucs2.encode\\`, parameter \\`points\\` must be an array of numbers, but received: \\`${getPreciseType(\n points\n )}\\`.`\n );\n }\n\n return String.fromCodePoint(...points);\n};\n\n/** ---------------------------------------------------------\n * * ***Converts a basic code point to its digit value for `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param codePoint - Unicode code point.\n * @returns Digit value.\n */\nfunction basicToDigit(codePoint: number): number {\n if (codePoint >= 0x30 && codePoint < 0x3a) return 26 + (codePoint - 0x30);\n if (codePoint >= 0x41 && codePoint < 0x5b) return codePoint - 0x41;\n if (codePoint >= 0x61 && codePoint < 0x7b) return codePoint - 0x61;\n return base;\n}\n\n/** ---------------------------------------------------------\n * * ***Converts a digit to a basic code point for `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param digit - Numeric value.\n * @param flag - Bias flag (0 or 1).\n * @returns Code point.\n */\nfunction digitToBasic(digit: number, flag: number): number {\n return digit + 22 + 75 * (digit < 26 ? 1 : 0) - Number(flag !== 0) * 32;\n}\n\n/** ---------------------------------------------------------\n * * ***Bias adaptation function for `Punycode-UtilsJS` encoding/decoding.***\n * ---------------------------------------------------------\n *\n * @param delta - Delta value.\n * @param numPoints - Number of code points.\n * @param firstTime - Indicates first adaptation.\n * @returns Adapted bias.\n */\nfunction adapt(delta: number, numPoints: number, firstTime: boolean): number {\n let k = 0;\n delta = firstTime ? floor(delta / damp) : delta >> 1;\n delta += floor(delta / numPoints);\n while (delta > ((base - tMin) * tMax) >> 1) {\n delta = floor(delta / (base - tMin));\n k += base;\n }\n return floor(k + ((base - tMin + 1) * delta) / (delta + skew));\n}\n\n/** ---------------------------------------------------------\n * * ***Decodes a `Punycode-UtilsJS` string to Unicode.***\n * ---------------------------------------------------------\n *\n * @param input - `Punycode-UtilsJS` string.\n * @returns Decoded Unicode string.\n */\nfunction decode(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.decode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const output: number[] = [];\n const inputLength = input.length;\n let i = 0,\n n = initialN,\n bias = initialBias;\n\n let basic = input.lastIndexOf(delimiter);\n if (basic < 0) basic = 0;\n\n for (let j = 0; j < basic; j++) {\n if (input.charCodeAt(j) >= 0x80) error(\"not-basic\");\n output.push(input.charCodeAt(j));\n }\n\n for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {\n const oldi = i;\n let w = 1;\n for (let k = base; ; k += base) {\n if (index >= inputLength) error(\"invalid-input\");\n const digit = basicToDigit(input.charCodeAt(index++));\n if (digit >= base) error(\"invalid-input\");\n if (digit > floor((maxInt - i) / w)) error(\"overflow\");\n i += digit * w;\n const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n if (digit < t) break;\n const baseMinusT = base - t;\n if (w > floor(maxInt / baseMinusT)) error(\"overflow\");\n w *= baseMinusT;\n }\n const out = output.length + 1;\n bias = adapt(i - oldi, out, oldi === 0);\n if (floor(i / out) > maxInt - n) error(\"overflow\");\n n += floor(i / out);\n i %= out;\n output.splice(i++, 0, n);\n }\n return String.fromCodePoint(...output);\n}\n\n/** ---------------------------------------------------------\n * * ***Encodes a Unicode string to `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param input - Unicode string.\n * @returns `Punycode-UtilsJS` string.\n */\nfunction encode(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.encode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const output: string[] = [];\n const points = ucs2decode(input);\n const inputLength = points.length;\n let n = initialN,\n delta = 0,\n bias = initialBias;\n\n for (const cp of points) if (cp < 0x80) output.push(stringFromCharCode(cp));\n const basicLength = output.length;\n let handledCPCount = basicLength;\n if (basicLength) output.push(delimiter);\n\n while (handledCPCount < inputLength) {\n let m = maxInt;\n for (const cp of points) if (cp >= n && cp < m) m = cp;\n\n const handledCPCountPlusOne = handledCPCount + 1;\n if (m - n > floor((maxInt - delta) / handledCPCountPlusOne))\n error(\"overflow\");\n delta += (m - n) * handledCPCountPlusOne;\n n = m;\n\n for (const cp of points) {\n if (cp < n) delta++;\n if (cp === n) {\n let q = delta;\n for (let k = base; ; k += base) {\n const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n if (q < t) break;\n output.push(\n stringFromCharCode(digitToBasic(t + ((q - t) % (base - t)), 0))\n );\n q = floor((q - t) / (base - t));\n }\n output.push(stringFromCharCode(digitToBasic(q, 0)));\n bias = adapt(\n delta,\n handledCPCountPlusOne,\n handledCPCount === basicLength\n );\n delta = 0;\n handledCPCount++;\n }\n }\n delta++;\n n++;\n }\n\n return output.join(\"\");\n}\n\n/** ---------------------------------------------------------\n * * ***Converts `Punycode-UtilsJS` to Unicode for domain names.***\n * ---------------------------------------------------------\n *\n * @param input - Domain or label.\n * @returns Unicode string.\n */\nfunction toUnicode(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.toUnicode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n return mapDomain(input, (str) =>\n regexPunycode.test(str) ? decode(str.slice(4).toLowerCase()) : str\n );\n}\n\n/** ---------------------------------------------------------\n * * ***Converts Unicode to ASCII (`Punycode-UtilsJS`) for domain names.***\n * ---------------------------------------------------------\n *\n * @param input - Domain or label.\n * @returns ASCII string.\n */\nfunction toASCII(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.toASCII\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n return mapDomain(input, (str) =>\n regexNonASCII.test(str) ? \"xn--\" + encode(str) : str\n );\n}\n\ntype PunycodeUtilsJS = {\n /** ---------------------------------------------------------\n * * ***Version of the `Punycode-UtilsJS` implementation.***\n * ---------------------------------------------------------\n *\n * @example\n * console.log(punycodeUtilsJS.version); // \"1.0.0\"\n */\n version: string;\n /** ---------------------------------------------------------\n * * ***UCS-2 utility functions.***\n * ---------------------------------------------------------\n */\n ucs2: {\n /** ---------------------------------------------------------\n * * ***Decodes a UCS-2 encoded string to an array of Unicode code points.***\n * ---------------------------------------------------------\n *\n * @param input - The UCS-2 string to decode.\n * @returns Array of Unicode code points.\n * @example\n * punycodeUtilsJS.ucs2.decode(\"𐍈\");\n * // ➔ [66376]\n */\n decode: (input: string) => number[];\n /** ---------------------------------------------------------\n * * ***Encodes an array of Unicode code points to a UCS-2 string.***\n * ---------------------------------------------------------\n *\n * @param points - Array of Unicode code points.\n * @returns Encoded string.\n * @example\n * punycodeUtilsJS.ucs2.encode([66376]);\n * // ➔ \"𐍈\"\n */\n encode: (points: number[]) => string;\n };\n /** ---------------------------------------------------------\n * * ***Decodes a `Punycode-UtilsJS` string to a Unicode string.***\n * ---------------------------------------------------------\n *\n * @param input - The `Punycode-UtilsJS` string to decode.\n * @returns Decoded Unicode string.\n * @example\n * punycodeUtilsJS.decode(\"xn--fsq\");\n * // ➔ \"ü\"\n */\n decode: (input: string) => string;\n /** ---------------------------------------------------------\n * * ***Encodes a Unicode string to `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param input - Unicode string to encode.\n * @returns `Punycode-UtilsJS` string.\n * @example\n * punycodeUtilsJS.encode(\"ü\");\n * // ➔ \"xn--fsq\"\n */\n encode: (input: string) => string;\n /** ---------------------------------------------------------\n * * ***Converts a Unicode domain or label to ASCII (`Punycode-UtilsJS`).***\n * ---------------------------------------------------------\n *\n * @param input - Domain or label string.\n * @returns ASCII string suitable for DNS.\n * @example\n * punycodeUtilsJS.toASCII(\"пример.рф\");\n * // ➔ \"xn--e1afmkfd.xn--p1ai\"\n */\n toASCII: (input: string) => string;\n /** ---------------------------------------------------------\n * * ***Converts an ASCII (`Punycode-UtilsJS`) domain or label to Unicode.***\n * ---------------------------------------------------------\n *\n * @param input - ASCII string (with xn-- prefix if needed).\n * @returns Unicode string.\n * @example\n * punycodeUtilsJS.toUnicode(\"xn--e1afmkfd.xn--p1ai\");\n * // ➔ \"пример.рф\"\n */\n toUnicode: (input: string) => string;\n};\n\n/** ---------------------------------------------------------\n * * ***`Punycode-UtilsJS` object exposing all API functions and version.***\n * ---------------------------------------------------------\n * Provides encoding and decoding of Unicode domain names to ASCII (`Punycode-UtilsJS`)\n * and vice versa.\n *\n * - Useful for IDN (Internationalized Domain Names) support.\n */\nconst punycodeUtilsJS: PunycodeUtilsJS = {\n version: \"1.0.0\",\n ucs2: {\n decode: ucs2decode,\n encode: ucs2encode\n },\n decode: decode,\n encode: encode,\n toASCII: toASCII,\n toUnicode: toUnicode\n};\n\n/**\n * Export individual functions.\n */\nexport { punycodeUtilsJS };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,SAAS;;;;AAKf,MAAM,OAAO,IACX,OAAO,GACP,OAAO,IACP,OAAO,IACP,OAAO;;;;AAKT,MAAM,cAAc,IAClB,WAAW,KACX,YAAY;;;;;AAMd,MAAM,gBAAgB;;;;;AAKtB,MAAM,gBAAgB;;;;;AAKtB,MAAM,kBAAkB;;;;AAKxB,MAAM,SAAiC;CACrC,UAAU;CACV,aAAa;CACb,iBAAiB;CAClB;;;;AAKD,MAAM,QAAQ,KAAK;;;;;AAKnB,MAAM,qBAAqB,OAAO;;;;;;;AAQlC,SAAS,MAAM,MAAkC;CAC/C,MAAM,IAAI,WAAW,OAAO,MAAM;;;;;;;;;;AAWpC,SAAS,IAAU,OAAY,IAAsB;CACnD,MAAM,SAAc,EAAE;CACtB,IAAI,SAAS,MAAM;CACnB,OAAO,UACL,IAAI,MAAM,SACR,OAAO,UAAU,GAAG,MAAM,QAAS;CAGvC,OAAO;;;;;;;;;;;AAYT,SAAS,UAAU,QAAgB,IAAmC;CACpE,MAAM,QAAQ,OAAO,MAAM,IAAI;CAC/B,IAAI,SAAS;CACb,IAAI,MAAM,SAAS,GAAG;EACpB,SAAS,MAAM,KAAK;EACpB,IAAI,MAAM,IAAI,SAAS,MAAM;;CAE/B,SAAS,OAAO,QAAQ,i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AI,OAAO,IAAI,MAAM,OAAO,GAAG;;IAEjC,OAAO,KAAK,mBAAmB,aAAa,GAAG,EAAE,CAAC,CAAC;IACnD,OAAO,MACL,OACA,uBACA,mBAAmB,YACpB;IACD,QAAQ;IACR;;;EAGJ;EACA;;CAGF,OAAO,OAAO,KAAK,GAAG;;;;;;;;;AAUxB,SAAS,UAAU,OAAuB;CACxC,eAAe,OAAO,EACpB,UAAU,EAAE,aAAa,gBACvB,8EAA8E,UAAU,sBAAsB,YAAY,MAC7H,CAAC;CAEF,OAAO,UAAU,QAAQ,QACvB,cAAc,KAAK,IAAI,GAAG,OAAO,IAAI,MAAM,EAAE,CAAC,aAAa,CAAC,GAAG,IAChE;;;;;;;;;AAUH,SAAS,QAAQ,OAAuB;CACtC,eAAe,OAAO,EACpB,UAAU,EAAE,aAAa,gBACvB,4EAA4E,UAAU,sBAAsB,YAAY,MAC3H,CAAC;CAEF,OAAO,UAAU,QAAQ,QACvB,cAAc,KAAK,IAAI,GAAG,SAAS,OAAO,IAAI,GAAG,IAClD;;;;;;;;;;AA8FH,MAAM,kBAAmC;CACvC,SAAS;CACT,MAAM;EACJ,QAAQ;EACR,QAAQ;EACT;CACO;CACA;CACC;CACE;CACZ"}
|
|
1
|
+
{"version":3,"file":"punyCode-Dwto1RpA.js","names":[],"sources":["../src/urls/utils/punyCode.ts"],"sourcesContent":["/** ---------------------------------------------------------\n * * ***Constants for `Punycode-UtilsJS` algorithm.***\n * ---------------------------------------------------------\n * These constants are used internally for encoding and decoding.\n *\n * Unicode domain names to ASCII (`Punycode-UtilsJS`) and vice versa.\n */\n\nimport { getPreciseType } from \"@/predicates/type/getPreciseType\";\nimport { assertIsString } from \"@/assertions/strings/assertIsString\";\n\n/**\n * Constant `maxInt` for validate.\n */\nconst maxInt = 2147483647;\n\n/**\n * Bootstring parameters for `Punycode-UtilsJS`.\n */\nconst base = 36,\n tMin = 1,\n tMax = 26,\n skew = 38,\n damp = 700;\n\n/**\n * Initial bias and code point.\n */\nconst initialBias = 72,\n initialN = 128,\n delimiter = \"-\";\n\n/**\n * Regular expressions used internally.\n * Matches `Punycode-UtilsJS` prefix.\n */\nconst regexPunycode = /^xn--/;\n/**\n * Regular expressions used internally.\n * Matches non-ASCII chars.\n */\nconst regexNonASCII = /[^\\0-\\x7F]/;\n/**\n * Regular expressions used internally.\n * Matches domain label separators.\n */\nconst regexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g;\n\n/**\n * Error messages used internally.\n */\nconst errors: Record<string, string> = {\n overflow: \"Overflow: input needs wider integers to process\",\n \"not-basic\": \"Illegal input >= 0x80 (not a basic code point)\",\n \"invalid-input\": \"Invalid input\"\n};\n\n/**\n * Aliases of `Math.floor`.\n */\nconst floor = Math.floor;\n/** \n * Aliases of `String.fromCharCode`.\n\n*/\nconst stringFromCharCode = String.fromCharCode;\n\n/** ---------------------------------------------------------\n * * ***Throws a RangeError with a predefined error message.***\n * ---------------------------------------------------------\n *\n * @param type - Key of the error type to throw.\n */\nfunction error(type: keyof typeof errors): never {\n throw new RangeError(errors[type]);\n}\n\n/** ---------------------------------------------------------\n * * ***Maps an array using a callback function.***\n * ---------------------------------------------------------\n *\n * @param array - Array to transform.\n * @param fn - Function to apply to each element.\n * @returns Transformed array.\n */\nfunction map<T, U>(array: T[], fn: (v: T) => U): U[] {\n const result: U[] = [];\n let length = array.length;\n while (length--) {\n if (array[length]) {\n result[length] = fn(array[length]!);\n }\n }\n return result;\n}\n\n/** ---------------------------------------------------------\n * * ***Maps a domain name using a callback on each label.***\n * ---------------------------------------------------------\n *\n * Handles email-like domains (local@domain).\n * @param domain - Domain string to process.\n * @param fn - Function applied to each domain label.\n * @returns Transformed domain string.\n */\nfunction mapDomain(domain: string, fn: (v: string) => string): string {\n const parts = domain.split(\"@\");\n let result = \"\";\n if (parts.length > 1) {\n result = parts[0] + \"@\";\n if (parts[1]) domain = parts[1];\n }\n domain = domain.replace(regexSeparators, \"\\x2E\");\n const labels = domain.split(\".\");\n return result + map(labels, fn).join(\".\");\n}\n\n/** ---------------------------------------------------------\n * * ***Converts a UCS-2 encoded string to an array of Unicode code points.***\n * ---------------------------------------------------------\n *\n * @param input - String to decode.\n * @returns Array of Unicode code points.\n */\nfunction ucs2decode(input: string): number[] {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.ucs2.decode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const output: number[] = [];\n let counter = 0;\n const length = input.length;\n while (counter < length) {\n const value = input.charCodeAt(counter++);\n if (value >= 0xd800 && value <= 0xdbff && counter < length) {\n const extra = input.charCodeAt(counter++);\n if ((extra & 0xfc00) === 0xdc00)\n output.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);\n else {\n output.push(value);\n counter--;\n }\n } else output.push(value);\n }\n return output;\n}\n\n/** ---------------------------------------------------------\n * * ***Encodes an array of Unicode code points to a string.***\n * ---------------------------------------------------------\n *\n * @param points - Array of Unicode code points.\n * @returns Encoded string.\n */\nconst ucs2encode = (points: number[]): string => {\n if (\n !Array.isArray(points) ||\n !points.every((p) => typeof p === \"number\" && Number.isFinite(p))\n ) {\n throw new TypeError(\n `Utils \\`punycodeUtilsJS.ucs2.encode\\`, parameter \\`points\\` must be an array of numbers, but received: \\`${getPreciseType(\n points\n )}\\`.`\n );\n }\n\n return String.fromCodePoint(...points);\n};\n\n/** ---------------------------------------------------------\n * * ***Converts a basic code point to its digit value for `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param codePoint - Unicode code point.\n * @returns Digit value.\n */\nfunction basicToDigit(codePoint: number): number {\n if (codePoint >= 0x30 && codePoint < 0x3a) return 26 + (codePoint - 0x30);\n if (codePoint >= 0x41 && codePoint < 0x5b) return codePoint - 0x41;\n if (codePoint >= 0x61 && codePoint < 0x7b) return codePoint - 0x61;\n return base;\n}\n\n/** ---------------------------------------------------------\n * * ***Converts a digit to a basic code point for `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param digit - Numeric value.\n * @param flag - Bias flag (0 or 1).\n * @returns Code point.\n */\nfunction digitToBasic(digit: number, flag: number): number {\n return digit + 22 + 75 * (digit < 26 ? 1 : 0) - Number(flag !== 0) * 32;\n}\n\n/** ---------------------------------------------------------\n * * ***Bias adaptation function for `Punycode-UtilsJS` encoding/decoding.***\n * ---------------------------------------------------------\n *\n * @param delta - Delta value.\n * @param numPoints - Number of code points.\n * @param firstTime - Indicates first adaptation.\n * @returns Adapted bias.\n */\nfunction adapt(delta: number, numPoints: number, firstTime: boolean): number {\n let k = 0;\n delta = firstTime ? floor(delta / damp) : delta >> 1;\n delta += floor(delta / numPoints);\n while (delta > ((base - tMin) * tMax) >> 1) {\n delta = floor(delta / (base - tMin));\n k += base;\n }\n return floor(k + ((base - tMin + 1) * delta) / (delta + skew));\n}\n\n/** ---------------------------------------------------------\n * * ***Decodes a `Punycode-UtilsJS` string to Unicode.***\n * ---------------------------------------------------------\n *\n * @param input - `Punycode-UtilsJS` string.\n * @returns Decoded Unicode string.\n */\nfunction decode(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.decode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const output: number[] = [];\n const inputLength = input.length;\n let i = 0,\n n = initialN,\n bias = initialBias;\n\n let basic = input.lastIndexOf(delimiter);\n if (basic < 0) basic = 0;\n\n for (let j = 0; j < basic; j++) {\n if (input.charCodeAt(j) >= 0x80) error(\"not-basic\");\n output.push(input.charCodeAt(j));\n }\n\n for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {\n const oldi = i;\n let w = 1;\n for (let k = base; ; k += base) {\n if (index >= inputLength) error(\"invalid-input\");\n const digit = basicToDigit(input.charCodeAt(index++));\n if (digit >= base) error(\"invalid-input\");\n if (digit > floor((maxInt - i) / w)) error(\"overflow\");\n i += digit * w;\n const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n if (digit < t) break;\n const baseMinusT = base - t;\n if (w > floor(maxInt / baseMinusT)) error(\"overflow\");\n w *= baseMinusT;\n }\n const out = output.length + 1;\n bias = adapt(i - oldi, out, oldi === 0);\n if (floor(i / out) > maxInt - n) error(\"overflow\");\n n += floor(i / out);\n i %= out;\n output.splice(i++, 0, n);\n }\n return String.fromCodePoint(...output);\n}\n\n/** ---------------------------------------------------------\n * * ***Encodes a Unicode string to `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param input - Unicode string.\n * @returns `Punycode-UtilsJS` string.\n */\nfunction encode(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.encode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n const output: string[] = [];\n const points = ucs2decode(input);\n const inputLength = points.length;\n let n = initialN,\n delta = 0,\n bias = initialBias;\n\n for (const cp of points) if (cp < 0x80) output.push(stringFromCharCode(cp));\n const basicLength = output.length;\n let handledCPCount = basicLength;\n if (basicLength) output.push(delimiter);\n\n while (handledCPCount < inputLength) {\n let m = maxInt;\n for (const cp of points) if (cp >= n && cp < m) m = cp;\n\n const handledCPCountPlusOne = handledCPCount + 1;\n if (m - n > floor((maxInt - delta) / handledCPCountPlusOne))\n error(\"overflow\");\n delta += (m - n) * handledCPCountPlusOne;\n n = m;\n\n for (const cp of points) {\n if (cp < n) delta++;\n if (cp === n) {\n let q = delta;\n for (let k = base; ; k += base) {\n const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;\n if (q < t) break;\n output.push(\n stringFromCharCode(digitToBasic(t + ((q - t) % (base - t)), 0))\n );\n q = floor((q - t) / (base - t));\n }\n output.push(stringFromCharCode(digitToBasic(q, 0)));\n bias = adapt(\n delta,\n handledCPCountPlusOne,\n handledCPCount === basicLength\n );\n delta = 0;\n handledCPCount++;\n }\n }\n delta++;\n n++;\n }\n\n return output.join(\"\");\n}\n\n/** ---------------------------------------------------------\n * * ***Converts `Punycode-UtilsJS` to Unicode for domain names.***\n * ---------------------------------------------------------\n *\n * @param input - Domain or label.\n * @returns Unicode string.\n */\nfunction toUnicode(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.toUnicode\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n return mapDomain(input, (str) =>\n regexPunycode.test(str) ? decode(str.slice(4).toLowerCase()) : str\n );\n}\n\n/** ---------------------------------------------------------\n * * ***Converts Unicode to ASCII (`Punycode-UtilsJS`) for domain names.***\n * ---------------------------------------------------------\n *\n * @param input - Domain or label.\n * @returns ASCII string.\n */\nfunction toASCII(input: string): string {\n assertIsString(input, {\n message: ({ currentType, validType }) =>\n `Utils \\`punycodeUtilsJS.toASCII\\`, parameter \\`input\\` must be of type \\`${validType}\\`, but received: \\`${currentType}\\`.`\n });\n\n return mapDomain(input, (str) =>\n regexNonASCII.test(str) ? \"xn--\" + encode(str) : str\n );\n}\n\ntype PunycodeUtilsJS = {\n /** ---------------------------------------------------------\n * * ***Version of the `Punycode-UtilsJS` implementation.***\n * ---------------------------------------------------------\n *\n * @example\n * console.log(punycodeUtilsJS.version); // \"1.0.0\"\n */\n version: string;\n /** ---------------------------------------------------------\n * * ***UCS-2 utility functions.***\n * ---------------------------------------------------------\n */\n ucs2: {\n /** ---------------------------------------------------------\n * * ***Decodes a UCS-2 encoded string to an array of Unicode code points.***\n * ---------------------------------------------------------\n *\n * @param input - The UCS-2 string to decode.\n * @returns Array of Unicode code points.\n * @example\n * punycodeUtilsJS.ucs2.decode(\"𐍈\");\n * // ➔ [66376]\n */\n decode: (input: string) => number[];\n /** ---------------------------------------------------------\n * * ***Encodes an array of Unicode code points to a UCS-2 string.***\n * ---------------------------------------------------------\n *\n * @param points - Array of Unicode code points.\n * @returns Encoded string.\n * @example\n * punycodeUtilsJS.ucs2.encode([66376]);\n * // ➔ \"𐍈\"\n */\n encode: (points: number[]) => string;\n };\n /** ---------------------------------------------------------\n * * ***Decodes a `Punycode-UtilsJS` string to a Unicode string.***\n * ---------------------------------------------------------\n *\n * @param input - The `Punycode-UtilsJS` string to decode.\n * @returns Decoded Unicode string.\n * @example\n * punycodeUtilsJS.decode(\"xn--fsq\");\n * // ➔ \"ü\"\n */\n decode: (input: string) => string;\n /** ---------------------------------------------------------\n * * ***Encodes a Unicode string to `Punycode-UtilsJS`.***\n * ---------------------------------------------------------\n *\n * @param input - Unicode string to encode.\n * @returns `Punycode-UtilsJS` string.\n * @example\n * punycodeUtilsJS.encode(\"ü\");\n * // ➔ \"xn--fsq\"\n */\n encode: (input: string) => string;\n /** ---------------------------------------------------------\n * * ***Converts a Unicode domain or label to ASCII (`Punycode-UtilsJS`).***\n * ---------------------------------------------------------\n *\n * @param input - Domain or label string.\n * @returns ASCII string suitable for DNS.\n * @example\n * punycodeUtilsJS.toASCII(\"пример.рф\");\n * // ➔ \"xn--e1afmkfd.xn--p1ai\"\n */\n toASCII: (input: string) => string;\n /** ---------------------------------------------------------\n * * ***Converts an ASCII (`Punycode-UtilsJS`) domain or label to Unicode.***\n * ---------------------------------------------------------\n *\n * @param input - ASCII string (with xn-- prefix if needed).\n * @returns Unicode string.\n * @example\n * punycodeUtilsJS.toUnicode(\"xn--e1afmkfd.xn--p1ai\");\n * // ➔ \"пример.рф\"\n */\n toUnicode: (input: string) => string;\n};\n\n/** ---------------------------------------------------------\n * * ***`Punycode-UtilsJS` object exposing all API functions and version.***\n * ---------------------------------------------------------\n * Provides encoding and decoding of Unicode domain names to ASCII (`Punycode-UtilsJS`)\n * and vice versa.\n *\n * - Useful for IDN (Internationalized Domain Names) support.\n */\nconst punycodeUtilsJS: PunycodeUtilsJS = {\n version: \"1.0.0\",\n ucs2: {\n decode: ucs2decode,\n encode: ucs2encode\n },\n decode: decode,\n encode: encode,\n toASCII: toASCII,\n toUnicode: toUnicode\n};\n\n/**\n * Export individual functions.\n */\nexport { punycode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AAc,KAAK,GAAG,IAAI,OAAO,IAAI,MAAM,CAAC,EAAE,YAAY,CAAC,IAAI,GACjE;AACF;;;;;;;;AASA,SAAS,QAAQ,OAAuB;CACtC,eAAe,OAAO,EACpB,UAAU,EAAE,aAAa,gBACvB,4EAA4E,UAAU,sBAAsB,YAAY,KAC5H,CAAC;CAED,OAAO,UAAU,QAAQ,QACvB,cAAc,KAAK,GAAG,IAAI,SAAS,OAAO,GAAG,IAAI,GACnD;AACF;;;;;;;;;AA6FA,MAAM,kBAAmC;CACvC,SAAS;CACT,MAAM;EACJ,QAAQ;EACR,QAAQ;CACV;CACQ;CACA;CACC;CACE;AACb"}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.13.
|
|
5
|
+
* Version: `3.13.1`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
|
-
import { A as isPlainObject, y as isNonEmptyString } from "./assertIsBoolean-
|
|
10
|
+
import { A as isPlainObject, y as isNonEmptyString } from "./assertIsBoolean-CWUs-I5l.js";
|
|
11
11
|
const normalizeString = (input) => {
|
|
12
12
|
return isNonEmptyString(input) ? input.trim() : "";
|
|
13
13
|
};
|
|
@@ -19,4 +19,4 @@ const removeSpaces = (value, options = { trimOnly: false }) => {
|
|
|
19
19
|
return value.replace(/\s+/g, "");
|
|
20
20
|
};
|
|
21
21
|
export { normalizeString as n, removeSpaces as t };
|
|
22
|
-
//# sourceMappingURL=removeSpaces-
|
|
22
|
+
//# sourceMappingURL=removeSpaces--8NW-HSx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeSpaces-
|
|
1
|
+
{"version":3,"file":"removeSpaces--8NW-HSx.js","names":[],"sources":["../src/strings/sanitizations/normalizeString.ts","../src/strings/sanitizations/removeSpaces.ts"],"sourcesContent":["import { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `normalizeString`.***\n * ----------------------------------------------------------\n * **Normalizes a string by ensuring it is a valid string and trimming whitespace.**\n * - **Behavior:**\n * - If the input is `undefined`, `null`, or an `empty string` after trimming,\n * it returns an empty string `(\"\")`.\n * @param {string | undefined | null} input - The input string to be normalize. If `null` or `undefined`, returns an empty string.\n * @returns {string} A trimmed string or an empty string if the input is invalid.\n * @example\n * normalizeString(\" Hello World \");\n * // ➔ \"Hello World\"\n * normalizeString(\" Hello World \");\n * // ➔ \"Hello World\"\n * normalizeString(\"\");\n * // ➔ \"\"\n * normalizeString(null);\n * // ➔ \"\"\n * normalizeString(undefined);\n * // ➔ \"\"\n */\nexport const normalizeString = (input: string | null | undefined): string => {\n return isNonEmptyString(input) ? input.trim() : \"\";\n};\n","import { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\ntype RemoveSpacesOptions = {\n /** If `true`, only trims the string, defaultValue: `false`.\n *\n * @default false\n */\n trimOnly?: boolean;\n};\n\n/** ----------------------------------------------------------\n * * ***Utility: `removeSpaces`.***\n * ----------------------------------------------------------\n * **Removes all spaces from a string or trims only, based on the options provided.**\n * - **Behavior:**\n * - If `trimOnly` is `true`, the string is simply trimmed.\n * - Otherwise, removes **all spaces**, tabs, newlines, etc.\n * - If the input is `null` or `undefined`, returns an empty string `(\"\")`.\n * @param {string | null | undefined} value - The input string to be processed. If `null` or `undefined`, returns an empty string.\n * @param {RemoveSpacesOptions} [options] - The options object.\n * @param {RemoveSpacesOptions[\"trimOnly\"]} [options.trimOnly=false] - If `true`, only trims the string without removing spaces inside.\n * @returns {string} The processed string.\n * @example\n * removeSpaces(\" Hello World \");\n * // ➔ \"HelloWorld\"\n * removeSpaces(\" Hello World \", { trimOnly: true });\n * // ➔ \"Hello World\"\n * removeSpaces(null);\n * // ➔ \"\"\n */\nexport const removeSpaces = (\n value: string | null | undefined,\n options: RemoveSpacesOptions = {\n trimOnly: false\n }\n): string => {\n if (!isNonEmptyString(value)) return \"\";\n\n if (!isPlainObject(options)) {\n options = {};\n }\n\n const { trimOnly = false } = options;\n\n if (trimOnly) return value.trim();\n\n // Remove all spaces (including tabs, newlines, etc.)\n return value.replace(/\\s+/g, \"\");\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,mBAAmB,UAA6C;CAC3E,OAAO,iBAAiB,KAAK,IAAI,MAAM,KAAK,IAAI;AAClD;;;;;;;;;;;;;;;;;;;;;;;;ACMA,MAAa,gBACX,OACA,UAA+B,EAC7B,UAAU,MACZ,MACW;CACX,IAAI,CAAC,iBAAiB,KAAK,GAAG,OAAO;CAErC,IAAI,CAAC,cAAc,OAAO,GACxB,UAAU,CAAC;CAGb,MAAM,EAAE,WAAW,UAAU;CAE7B,IAAI,UAAU,OAAO,MAAM,KAAK;CAGhC,OAAO,MAAM,QAAQ,QAAQ,EAAE;AACjC"}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/utils-js
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `3.13.
|
|
5
|
+
* Version: `3.13.1`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/utils-js`
|
|
8
8
|
* ========================================================================
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
|
-
const require_assertIsBoolean = require('./assertIsBoolean-
|
|
11
|
+
const require_assertIsBoolean = require('./assertIsBoolean-D41HrTB_.cjs');
|
|
12
12
|
const normalizeString = (input) => {
|
|
13
13
|
return require_assertIsBoolean.isNonEmptyString(input) ? input.trim() : "";
|
|
14
14
|
};
|
|
@@ -31,4 +31,4 @@ Object.defineProperty(exports, 'removeSpaces', {
|
|
|
31
31
|
return removeSpaces;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
//# sourceMappingURL=removeSpaces-
|
|
34
|
+
//# sourceMappingURL=removeSpaces-CmrrkeXz.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeSpaces-
|
|
1
|
+
{"version":3,"file":"removeSpaces-CmrrkeXz.cjs","names":["isNonEmptyString","isNonEmptyString","isPlainObject"],"sources":["../src/strings/sanitizations/normalizeString.ts","../src/strings/sanitizations/removeSpaces.ts"],"sourcesContent":["import { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\n/** ----------------------------------------------------------\n * * ***Utility: `normalizeString`.***\n * ----------------------------------------------------------\n * **Normalizes a string by ensuring it is a valid string and trimming whitespace.**\n * - **Behavior:**\n * - If the input is `undefined`, `null`, or an `empty string` after trimming,\n * it returns an empty string `(\"\")`.\n * @param {string | undefined | null} input - The input string to be normalize. If `null` or `undefined`, returns an empty string.\n * @returns {string} A trimmed string or an empty string if the input is invalid.\n * @example\n * normalizeString(\" Hello World \");\n * // ➔ \"Hello World\"\n * normalizeString(\" Hello World \");\n * // ➔ \"Hello World\"\n * normalizeString(\"\");\n * // ➔ \"\"\n * normalizeString(null);\n * // ➔ \"\"\n * normalizeString(undefined);\n * // ➔ \"\"\n */\nexport const normalizeString = (input: string | null | undefined): string => {\n return isNonEmptyString(input) ? input.trim() : \"\";\n};\n","import { isPlainObject } from \"@/predicates/is/isPlainObject\";\nimport { isNonEmptyString } from \"@/predicates/is/isNonEmptyString\";\n\ntype RemoveSpacesOptions = {\n /** If `true`, only trims the string, defaultValue: `false`.\n *\n * @default false\n */\n trimOnly?: boolean;\n};\n\n/** ----------------------------------------------------------\n * * ***Utility: `removeSpaces`.***\n * ----------------------------------------------------------\n * **Removes all spaces from a string or trims only, based on the options provided.**\n * - **Behavior:**\n * - If `trimOnly` is `true`, the string is simply trimmed.\n * - Otherwise, removes **all spaces**, tabs, newlines, etc.\n * - If the input is `null` or `undefined`, returns an empty string `(\"\")`.\n * @param {string | null | undefined} value - The input string to be processed. If `null` or `undefined`, returns an empty string.\n * @param {RemoveSpacesOptions} [options] - The options object.\n * @param {RemoveSpacesOptions[\"trimOnly\"]} [options.trimOnly=false] - If `true`, only trims the string without removing spaces inside.\n * @returns {string} The processed string.\n * @example\n * removeSpaces(\" Hello World \");\n * // ➔ \"HelloWorld\"\n * removeSpaces(\" Hello World \", { trimOnly: true });\n * // ➔ \"Hello World\"\n * removeSpaces(null);\n * // ➔ \"\"\n */\nexport const removeSpaces = (\n value: string | null | undefined,\n options: RemoveSpacesOptions = {\n trimOnly: false\n }\n): string => {\n if (!isNonEmptyString(value)) return \"\";\n\n if (!isPlainObject(options)) {\n options = {};\n }\n\n const { trimOnly = false } = options;\n\n if (trimOnly) return value.trim();\n\n // Remove all spaces (including tabs, newlines, etc.)\n return value.replace(/\\s+/g, \"\");\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,mBAAmB,UAA6C;CAC3E,OAAOA,yCAAiB,KAAK,IAAI,MAAM,KAAK,IAAI;AAClD;;;;;;;;;;;;;;;;;;;;;;;;ACMA,MAAa,gBACX,OACA,UAA+B,EAC7B,UAAU,MACZ,MACW;CACX,IAAI,CAACC,yCAAiB,KAAK,GAAG,OAAO;CAErC,IAAI,CAACC,sCAAc,OAAO,GACxB,UAAU,CAAC;CAGb,MAAM,EAAE,WAAW,UAAU;CAE7B,IAAI,UAAU,OAAO,MAAM,KAAK;CAGhC,OAAO,MAAM,QAAQ,QAAQ,EAAE;AACjC"}
|