umt 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (362) hide show
  1. package/module/Array/chunk.js +5 -3
  2. package/module/Array/chunk.js.map +1 -1
  3. package/module/Array/dualPivotQuickSort.d.ts +1 -2
  4. package/module/Array/dualPivotQuickSort.js +5 -26
  5. package/module/Array/dualPivotQuickSort.js.map +1 -1
  6. package/module/Array/quickSort.js +7 -25
  7. package/module/Array/quickSort.js.map +1 -1
  8. package/module/Array/sortingHelpers/applyInsertionSortIfNeeded.d.ts +13 -0
  9. package/module/Array/sortingHelpers/applyInsertionSortIfNeeded.js +20 -0
  10. package/module/Array/sortingHelpers/applyInsertionSortIfNeeded.js.map +1 -0
  11. package/module/Array/sortingHelpers/rangeValidator.d.ts +17 -0
  12. package/module/Array/sortingHelpers/rangeValidator.js +26 -0
  13. package/module/Array/sortingHelpers/rangeValidator.js.map +1 -0
  14. package/module/Validate/object/core.d.ts +2 -6
  15. package/module/Validate/object/core.js.map +1 -1
  16. package/module/Validate/type.d.ts +1 -0
  17. package/module/es5/Array/chunk.js +5 -3
  18. package/module/es5/Array/dualPivotQuickSort.d.ts +1 -2
  19. package/module/es5/Array/dualPivotQuickSort.js +8 -28
  20. package/module/es5/Array/quickSort.js +10 -25
  21. package/module/es5/Array/sortingHelpers/applyInsertionSortIfNeeded.d.ts +13 -0
  22. package/module/es5/Array/sortingHelpers/applyInsertionSortIfNeeded.js +25 -0
  23. package/module/es5/Array/sortingHelpers/rangeValidator.d.ts +17 -0
  24. package/module/es5/Array/sortingHelpers/rangeValidator.js +35 -0
  25. package/module/es5/Validate/object/core.d.ts +2 -6
  26. package/module/es5/Validate/type.d.ts +1 -0
  27. package/module/es5/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +21 -17
  29. package/module/es5/tests/integration/Array/drop-and-first.test.d.ts +0 -1
  30. package/module/es5/tests/integration/Array/drop-and-first.test.js +0 -34
  31. package/module/es5/tests/integration/Tool/parseJson-and-Validate.test.d.ts +0 -1
  32. package/module/es5/tests/integration/Tool/parseJson-and-Validate.test.js +0 -80
  33. package/module/es5/tests/unit/Advance/rangeAdvance.test.d.ts +0 -1
  34. package/module/es5/tests/unit/Advance/rangeAdvance.test.js +0 -26
  35. package/module/es5/tests/unit/Array/arraysJoin.test.d.ts +0 -1
  36. package/module/es5/tests/unit/Array/arraysJoin.test.js +0 -19
  37. package/module/es5/tests/unit/Array/binarySearch.test.d.ts +0 -1
  38. package/module/es5/tests/unit/Array/binarySearch.test.js +0 -32
  39. package/module/es5/tests/unit/Array/checkFlagAlignment.test.d.ts +0 -1
  40. package/module/es5/tests/unit/Array/checkFlagAlignment.test.js +0 -206
  41. package/module/es5/tests/unit/Array/chunk.test.d.ts +0 -1
  42. package/module/es5/tests/unit/Array/chunk.test.js +0 -51
  43. package/module/es5/tests/unit/Array/compact.test.d.ts +0 -1
  44. package/module/es5/tests/unit/Array/compact.test.js +0 -53
  45. package/module/es5/tests/unit/Array/compareFunctionDefault.test.d.ts +0 -1
  46. package/module/es5/tests/unit/Array/compareFunctionDefault.test.js +0 -29
  47. package/module/es5/tests/unit/Array/drop.test.d.ts +0 -1
  48. package/module/es5/tests/unit/Array/drop.test.js +0 -84
  49. package/module/es5/tests/unit/Array/dualPivotQuickSort.test.d.ts +0 -1
  50. package/module/es5/tests/unit/Array/dualPivotQuickSort.test.js +0 -87
  51. package/module/es5/tests/unit/Array/first.test.d.ts +0 -1
  52. package/module/es5/tests/unit/Array/first.test.js +0 -28
  53. package/module/es5/tests/unit/Array/generateNumberArray.test.d.ts +0 -1
  54. package/module/es5/tests/unit/Array/generateNumberArray.test.js +0 -34
  55. package/module/es5/tests/unit/Array/getArraysCommon.test.d.ts +0 -1
  56. package/module/es5/tests/unit/Array/getArraysCommon.test.js +0 -40
  57. package/module/es5/tests/unit/Array/getArraysDiff.test.d.ts +0 -1
  58. package/module/es5/tests/unit/Array/getArraysDiff.test.js +0 -99
  59. package/module/es5/tests/unit/Array/groupBy.test.d.ts +0 -1
  60. package/module/es5/tests/unit/Array/groupBy.test.js +0 -87
  61. package/module/es5/tests/unit/Array/insertionSort.test.d.ts +0 -1
  62. package/module/es5/tests/unit/Array/insertionSort.test.js +0 -37
  63. package/module/es5/tests/unit/Array/mergeSort.test.d.ts +0 -1
  64. package/module/es5/tests/unit/Array/mergeSort.test.js +0 -49
  65. package/module/es5/tests/unit/Array/pop.test.d.ts +0 -1
  66. package/module/es5/tests/unit/Array/pop.test.js +0 -50
  67. package/module/es5/tests/unit/Array/quickSort.test.d.ts +0 -1
  68. package/module/es5/tests/unit/Array/quickSort.test.js +0 -118
  69. package/module/es5/tests/unit/Array/randomSelect.test.d.ts +0 -1
  70. package/module/es5/tests/unit/Array/randomSelect.test.js +0 -51
  71. package/module/es5/tests/unit/Array/range.test.d.ts +0 -1
  72. package/module/es5/tests/unit/Array/range.test.js +0 -42
  73. package/module/es5/tests/unit/Array/shuffle.test.d.ts +0 -1
  74. package/module/es5/tests/unit/Array/shuffle.test.js +0 -84
  75. package/module/es5/tests/unit/Array/shuffle2DArray.test.d.ts +0 -1
  76. package/module/es5/tests/unit/Array/shuffle2DArray.test.js +0 -90
  77. package/module/es5/tests/unit/Array/sum.test.d.ts +0 -1
  78. package/module/es5/tests/unit/Array/sum.test.js +0 -44
  79. package/module/es5/tests/unit/Array/timSort.test.d.ts +0 -1
  80. package/module/es5/tests/unit/Array/timSort.test.js +0 -128
  81. package/module/es5/tests/unit/Array/zip.test.d.ts +0 -1
  82. package/module/es5/tests/unit/Array/zip.test.js +0 -69
  83. package/module/es5/tests/unit/Array/zipLongest.test.d.ts +0 -1
  84. package/module/es5/tests/unit/Array/zipLongest.test.js +0 -74
  85. package/module/es5/tests/unit/Color/cmykToRgba.test.d.ts +0 -1
  86. package/module/es5/tests/unit/Color/cmykToRgba.test.js +0 -58
  87. package/module/es5/tests/unit/Color/hexaToRgba.test.d.ts +0 -1
  88. package/module/es5/tests/unit/Color/hexaToRgba.test.js +0 -115
  89. package/module/es5/tests/unit/Color/hslaToRgba.test.d.ts +0 -1
  90. package/module/es5/tests/unit/Color/hslaToRgba.test.js +0 -141
  91. package/module/es5/tests/unit/Color/rgbaToCmyk.test.d.ts +0 -1
  92. package/module/es5/tests/unit/Color/rgbaToCmyk.test.js +0 -139
  93. package/module/es5/tests/unit/Color/rgbaToHexA.test.d.ts +0 -1
  94. package/module/es5/tests/unit/Color/rgbaToHexA.test.js +0 -114
  95. package/module/es5/tests/unit/Color/rgbaToHsla.test.d.ts +0 -1
  96. package/module/es5/tests/unit/Color/rgbaToHsla.test.js +0 -190
  97. package/module/es5/tests/unit/Consts/clock.test.d.ts +0 -1
  98. package/module/es5/tests/unit/Consts/clock.test.js +0 -71
  99. package/module/es5/tests/unit/Consts/httpClientErrorStatus.test.d.ts +0 -1
  100. package/module/es5/tests/unit/Consts/httpClientErrorStatus.test.js +0 -33
  101. package/module/es5/tests/unit/Consts/httpInformationalStatus.test.d.ts +0 -1
  102. package/module/es5/tests/unit/Consts/httpInformationalStatus.test.js +0 -13
  103. package/module/es5/tests/unit/Consts/httpRedirectionStatus.test.d.ts +0 -1
  104. package/module/es5/tests/unit/Consts/httpRedirectionStatus.test.js +0 -16
  105. package/module/es5/tests/unit/Consts/httpServerErrorStatus.test.d.ts +0 -1
  106. package/module/es5/tests/unit/Consts/httpServerErrorStatus.test.js +0 -15
  107. package/module/es5/tests/unit/Consts/httpStatus.test.d.ts +0 -1
  108. package/module/es5/tests/unit/Consts/httpStatus.test.js +0 -82
  109. package/module/es5/tests/unit/Consts/httpSuccessStatus.test.d.ts +0 -1
  110. package/module/es5/tests/unit/Consts/httpSuccessStatus.test.js +0 -16
  111. package/module/es5/tests/unit/Date/birthday.test.d.ts +0 -1
  112. package/module/es5/tests/unit/Date/birthday.test.js +0 -31
  113. package/module/es5/tests/unit/Date/dateRange.test.d.ts +0 -1
  114. package/module/es5/tests/unit/Date/dateRange.test.js +0 -40
  115. package/module/es5/tests/unit/Date/dayOfWeek.test.d.ts +0 -1
  116. package/module/es5/tests/unit/Date/dayOfWeek.test.js +0 -39
  117. package/module/es5/tests/unit/Date/deleteSpace.test.d.ts +0 -1
  118. package/module/es5/tests/unit/Date/deleteSpace.test.js +0 -35
  119. package/module/es5/tests/unit/Date/format.test.d.ts +0 -1
  120. package/module/es5/tests/unit/Date/format.test.js +0 -50
  121. package/module/es5/tests/unit/Date/getDay.test.d.ts +0 -1
  122. package/module/es5/tests/unit/Date/getDay.test.js +0 -40
  123. package/module/es5/tests/unit/Date/getTimezoneOffsetString.test.d.ts +0 -1
  124. package/module/es5/tests/unit/Date/getTimezoneOffsetString.test.js +0 -26
  125. package/module/es5/tests/unit/Date/isLeapYear.test.d.ts +0 -1
  126. package/module/es5/tests/unit/Date/isLeapYear.test.js +0 -30
  127. package/module/es5/tests/unit/Date/new.test.d.ts +0 -1
  128. package/module/es5/tests/unit/Date/new.test.js +0 -39
  129. package/module/es5/tests/unit/Date/now.test.d.ts +0 -1
  130. package/module/es5/tests/unit/Date/now.test.js +0 -42
  131. package/module/es5/tests/unit/Error/safeExecute.test.d.ts +0 -1
  132. package/module/es5/tests/unit/Error/safeExecute.test.js +0 -75
  133. package/module/es5/tests/unit/Function/curry.test.d.ts +0 -1
  134. package/module/es5/tests/unit/Function/curry.test.js +0 -138
  135. package/module/es5/tests/unit/IP/cidrToLong.test.d.ts +0 -1
  136. package/module/es5/tests/unit/IP/cidrToLong.test.js +0 -32
  137. package/module/es5/tests/unit/IP/cidrToSubnetMask.test.d.ts +0 -1
  138. package/module/es5/tests/unit/IP/cidrToSubnetMask.test.js +0 -36
  139. package/module/es5/tests/unit/IP/getIpClass.test.d.ts +0 -1
  140. package/module/es5/tests/unit/IP/getIpClass.test.js +0 -36
  141. package/module/es5/tests/unit/IP/getNetworkAddress.test.d.ts +0 -1
  142. package/module/es5/tests/unit/IP/getNetworkAddress.test.js +0 -40
  143. package/module/es5/tests/unit/IP/ipToBinaryString.test.d.ts +0 -1
  144. package/module/es5/tests/unit/IP/ipToBinaryString.test.js +0 -46
  145. package/module/es5/tests/unit/IP/ipToLong.test.d.ts +0 -1
  146. package/module/es5/tests/unit/IP/ipToLong.test.js +0 -34
  147. package/module/es5/tests/unit/IP/isInRange.test.d.ts +0 -1
  148. package/module/es5/tests/unit/IP/isInRange.test.js +0 -82
  149. package/module/es5/tests/unit/IP/isPrivateIp.test.d.ts +0 -1
  150. package/module/es5/tests/unit/IP/isPrivateIp.test.js +0 -26
  151. package/module/es5/tests/unit/IP/longToIp.test.d.ts +0 -1
  152. package/module/es5/tests/unit/IP/longToIp.test.js +0 -39
  153. package/module/es5/tests/unit/IP/subnetMaskToCidr.test.d.ts +0 -1
  154. package/module/es5/tests/unit/IP/subnetMaskToCidr.test.js +0 -41
  155. package/module/es5/tests/unit/Math/addition.test.d.ts +0 -1
  156. package/module/es5/tests/unit/Math/addition.test.js +0 -79
  157. package/module/es5/tests/unit/Math/average.test.d.ts +0 -1
  158. package/module/es5/tests/unit/Math/average.test.js +0 -48
  159. package/module/es5/tests/unit/Math/bitwise.test.d.ts +0 -1
  160. package/module/es5/tests/unit/Math/bitwise.test.js +0 -62
  161. package/module/es5/tests/unit/Math/calculator/calculator.test.d.ts +0 -1
  162. package/module/es5/tests/unit/Math/calculator/calculator.test.js +0 -76
  163. package/module/es5/tests/unit/Math/calculator/calculatorInitialization.test.d.ts +0 -1
  164. package/module/es5/tests/unit/Math/calculator/calculatorInitialization.test.js +0 -21
  165. package/module/es5/tests/unit/Math/calculator/convertCurrency.test.d.ts +0 -1
  166. package/module/es5/tests/unit/Math/calculator/convertCurrency.test.js +0 -40
  167. package/module/es5/tests/unit/Math/calculator/literalExpression.test.d.ts +0 -1
  168. package/module/es5/tests/unit/Math/calculator/literalExpression.test.js +0 -51
  169. package/module/es5/tests/unit/Math/degToRad.test.d.ts +0 -1
  170. package/module/es5/tests/unit/Math/degToRad.test.js +0 -50
  171. package/module/es5/tests/unit/Math/deviationValue.test.d.ts +0 -1
  172. package/module/es5/tests/unit/Math/deviationValue.test.js +0 -30
  173. package/module/es5/tests/unit/Math/division.test.d.ts +0 -1
  174. package/module/es5/tests/unit/Math/division.test.js +0 -81
  175. package/module/es5/tests/unit/Math/factorial.test.d.ts +0 -1
  176. package/module/es5/tests/unit/Math/factorial.test.js +0 -26
  177. package/module/es5/tests/unit/Math/factorize.test.d.ts +0 -1
  178. package/module/es5/tests/unit/Math/factorize.test.js +0 -38
  179. package/module/es5/tests/unit/Math/flexibleNumberConversion.test.d.ts +0 -1
  180. package/module/es5/tests/unit/Math/flexibleNumberConversion.test.js +0 -195
  181. package/module/es5/tests/unit/Math/gcd.test.d.ts +0 -1
  182. package/module/es5/tests/unit/Math/gcd.test.js +0 -35
  183. package/module/es5/tests/unit/Math/getDecimalLength.test.d.ts +0 -1
  184. package/module/es5/tests/unit/Math/getDecimalLength.test.js +0 -44
  185. package/module/es5/tests/unit/Math/lcm.test.d.ts +0 -1
  186. package/module/es5/tests/unit/Math/lcm.test.js +0 -43
  187. package/module/es5/tests/unit/Math/linearCongruentialGenerator.test.d.ts +0 -1
  188. package/module/es5/tests/unit/Math/linearCongruentialGenerator.test.js +0 -25
  189. package/module/es5/tests/unit/Math/mathConverter.test.d.ts +0 -1
  190. package/module/es5/tests/unit/Math/mathConverter.test.js +0 -37
  191. package/module/es5/tests/unit/Math/mathSeparator.test.d.ts +0 -1
  192. package/module/es5/tests/unit/Math/mathSeparator.test.js +0 -59
  193. package/module/es5/tests/unit/Math/max.test.d.ts +0 -1
  194. package/module/es5/tests/unit/Math/max.test.js +0 -22
  195. package/module/es5/tests/unit/Math/median.test.d.ts +0 -1
  196. package/module/es5/tests/unit/Math/median.test.js +0 -17
  197. package/module/es5/tests/unit/Math/min.test.d.ts +0 -1
  198. package/module/es5/tests/unit/Math/min.test.js +0 -22
  199. package/module/es5/tests/unit/Math/multiples.test.d.ts +0 -1
  200. package/module/es5/tests/unit/Math/multiples.test.js +0 -30
  201. package/module/es5/tests/unit/Math/multiplication.test.d.ts +0 -1
  202. package/module/es5/tests/unit/Math/multiplication.test.js +0 -48
  203. package/module/es5/tests/unit/Math/nCr.test.d.ts +0 -1
  204. package/module/es5/tests/unit/Math/nCr.test.js +0 -34
  205. package/module/es5/tests/unit/Math/nHr.test.d.ts +0 -1
  206. package/module/es5/tests/unit/Math/nHr.test.js +0 -35
  207. package/module/es5/tests/unit/Math/nPr.test.d.ts +0 -1
  208. package/module/es5/tests/unit/Math/nPr.test.js +0 -38
  209. package/module/es5/tests/unit/Math/primeFactorization.test.d.ts +0 -1
  210. package/module/es5/tests/unit/Math/primeFactorization.test.js +0 -84
  211. package/module/es5/tests/unit/Math/quotient.test.d.ts +0 -1
  212. package/module/es5/tests/unit/Math/quotient.test.js +0 -36
  213. package/module/es5/tests/unit/Math/radToDeg.test.d.ts +0 -1
  214. package/module/es5/tests/unit/Math/radToDeg.test.js +0 -50
  215. package/module/es5/tests/unit/Math/random.test.d.ts +0 -1
  216. package/module/es5/tests/unit/Math/random.test.js +0 -61
  217. package/module/es5/tests/unit/Math/reduce.test.d.ts +0 -1
  218. package/module/es5/tests/unit/Math/reduce.test.js +0 -93
  219. package/module/es5/tests/unit/Math/repeatedTrial.test.d.ts +0 -1
  220. package/module/es5/tests/unit/Math/repeatedTrial.test.js +0 -39
  221. package/module/es5/tests/unit/Math/roundOf.test.d.ts +0 -1
  222. package/module/es5/tests/unit/Math/roundOf.test.js +0 -40
  223. package/module/es5/tests/unit/Math/solveEquation.test.d.ts +0 -1
  224. package/module/es5/tests/unit/Math/solveEquation.test.js +0 -24
  225. package/module/es5/tests/unit/Math/standardDeviation.test.d.ts +0 -1
  226. package/module/es5/tests/unit/Math/standardDeviation.test.js +0 -23
  227. package/module/es5/tests/unit/Math/subtract.test.d.ts +0 -1
  228. package/module/es5/tests/unit/Math/subtract.test.js +0 -46
  229. package/module/es5/tests/unit/Math/toBaseN.test.d.ts +0 -1
  230. package/module/es5/tests/unit/Math/toBaseN.test.js +0 -40
  231. package/module/es5/tests/unit/Math/toCelsius.test.d.ts +0 -1
  232. package/module/es5/tests/unit/Math/toCelsius.test.js +0 -18
  233. package/module/es5/tests/unit/Math/toKelvin.test.d.ts +0 -1
  234. package/module/es5/tests/unit/Math/toKelvin.test.js +0 -18
  235. package/module/es5/tests/unit/Math/uuidv7.test.d.ts +0 -1
  236. package/module/es5/tests/unit/Math/uuidv7.test.js +0 -33
  237. package/module/es5/tests/unit/Math/valueSwap.test.d.ts +0 -1
  238. package/module/es5/tests/unit/Math/valueSwap.test.js +0 -28
  239. package/module/es5/tests/unit/Math/xoshiro256.test.d.ts +0 -1
  240. package/module/es5/tests/unit/Math/xoshiro256.test.js +0 -33
  241. package/module/es5/tests/unit/Object/has.test.d.ts +0 -1
  242. package/module/es5/tests/unit/Object/has.test.js +0 -60
  243. package/module/es5/tests/unit/Object/keyBy.test.d.ts +0 -1
  244. package/module/es5/tests/unit/Object/keyBy.test.js +0 -120
  245. package/module/es5/tests/unit/Object/pick.test.d.ts +0 -1
  246. package/module/es5/tests/unit/Object/pick.test.js +0 -109
  247. package/module/es5/tests/unit/Object/pickDeep.test.d.ts +0 -1
  248. package/module/es5/tests/unit/Object/pickDeep.test.js +0 -222
  249. package/module/es5/tests/unit/Simple/Array/quickSortSimple.test.d.ts +0 -1
  250. package/module/es5/tests/unit/Simple/Array/quickSortSimple.test.js +0 -18
  251. package/module/es5/tests/unit/Simple/Date/dayOfWeekSimple.test.d.ts +0 -1
  252. package/module/es5/tests/unit/Simple/Date/dayOfWeekSimple.test.js +0 -58
  253. package/module/es5/tests/unit/Simple/Math/deviationValueSimple.test.d.ts +0 -1
  254. package/module/es5/tests/unit/Simple/Math/deviationValueSimple.test.js +0 -43
  255. package/module/es5/tests/unit/String/deleteSpaces.test.d.ts +0 -1
  256. package/module/es5/tests/unit/String/deleteSpaces.test.js +0 -22
  257. package/module/es5/tests/unit/String/formatString.test.d.ts +0 -1
  258. package/module/es5/tests/unit/String/formatString.test.js +0 -47
  259. package/module/es5/tests/unit/String/fromBase64.test.d.ts +0 -1
  260. package/module/es5/tests/unit/String/fromBase64.test.js +0 -37
  261. package/module/es5/tests/unit/String/hasNoLetters.test.d.ts +0 -1
  262. package/module/es5/tests/unit/String/hasNoLetters.test.js +0 -29
  263. package/module/es5/tests/unit/String/padEnd.test.d.ts +0 -1
  264. package/module/es5/tests/unit/String/padEnd.test.js +0 -22
  265. package/module/es5/tests/unit/String/padStart.test.d.ts +0 -1
  266. package/module/es5/tests/unit/String/padStart.test.js +0 -40
  267. package/module/es5/tests/unit/String/randomString.test.d.ts +0 -1
  268. package/module/es5/tests/unit/String/randomString.test.js +0 -21
  269. package/module/es5/tests/unit/String/randomStringInitialization.test.d.ts +0 -1
  270. package/module/es5/tests/unit/String/randomStringInitialization.test.js +0 -25
  271. package/module/es5/tests/unit/String/reverseString.test.d.ts +0 -1
  272. package/module/es5/tests/unit/String/reverseString.test.js +0 -35
  273. package/module/es5/tests/unit/String/toBase64.test.d.ts +0 -1
  274. package/module/es5/tests/unit/String/toBase64.test.js +0 -20
  275. package/module/es5/tests/unit/String/toHalfWidth.test.d.ts +0 -1
  276. package/module/es5/tests/unit/String/toHalfWidth.test.js +0 -16
  277. package/module/es5/tests/unit/String/trimCharacters.test.d.ts +0 -1
  278. package/module/es5/tests/unit/String/trimCharacters.test.js +0 -17
  279. package/module/es5/tests/unit/String/trimEndCharacters.test.d.ts +0 -1
  280. package/module/es5/tests/unit/String/trimEndCharacters.test.js +0 -33
  281. package/module/es5/tests/unit/String/trimStartCharacters.test.d.ts +0 -1
  282. package/module/es5/tests/unit/String/trimStartCharacters.test.js +0 -33
  283. package/module/es5/tests/unit/Time/convertTime.test.d.ts +0 -1
  284. package/module/es5/tests/unit/Time/convertTime.test.js +0 -135
  285. package/module/es5/tests/unit/Time/normalizeTimeUnit.test.d.ts +0 -1
  286. package/module/es5/tests/unit/Time/normalizeTimeUnit.test.js +0 -29
  287. package/module/es5/tests/unit/Tool/createPipeline.test.d.ts +0 -1
  288. package/module/es5/tests/unit/Tool/createPipeline.test.js +0 -184
  289. package/module/es5/tests/unit/Tool/parseJson.test.d.ts +0 -1
  290. package/module/es5/tests/unit/Tool/parseJson.test.js +0 -46
  291. package/module/es5/tests/unit/Tool/pipe.test.d.ts +0 -1
  292. package/module/es5/tests/unit/Tool/pipe.test.js +0 -445
  293. package/module/es5/tests/unit/UA/extractBrowserFromUserAgent.test.d.ts +0 -1
  294. package/module/es5/tests/unit/UA/extractBrowserFromUserAgent.test.js +0 -47
  295. package/module/es5/tests/unit/UA/extractDeviceFromUserAgent.test.d.ts +0 -1
  296. package/module/es5/tests/unit/UA/extractDeviceFromUserAgent.test.js +0 -55
  297. package/module/es5/tests/unit/UA/extractOsFromUserAgent.test.d.ts +0 -1
  298. package/module/es5/tests/unit/UA/extractOsFromUserAgent.test.js +0 -57
  299. package/module/es5/tests/unit/UA/parseUserAgent.test.d.ts +0 -1
  300. package/module/es5/tests/unit/UA/parseUserAgent.test.js +0 -95
  301. package/module/es5/tests/unit/Unit/unitConverterInitialization.test.d.ts +0 -1
  302. package/module/es5/tests/unit/Unit/unitConverterInitialization.test.js +0 -40
  303. package/module/es5/tests/unit/Validate/array/core.test.d.ts +0 -1
  304. package/module/es5/tests/unit/Validate/array/core.test.js +0 -86
  305. package/module/es5/tests/unit/Validate/boolean/core.test.d.ts +0 -1
  306. package/module/es5/tests/unit/Validate/boolean/core.test.js +0 -29
  307. package/module/es5/tests/unit/Validate/core/core.test.d.ts +0 -1
  308. package/module/es5/tests/unit/Validate/core/core.test.js +0 -87
  309. package/module/es5/tests/unit/Validate/isArray.test.d.ts +0 -1
  310. package/module/es5/tests/unit/Validate/isArray.test.js +0 -36
  311. package/module/es5/tests/unit/Validate/isDictionaryObject.test.d.ts +0 -1
  312. package/module/es5/tests/unit/Validate/isDictionaryObject.test.js +0 -62
  313. package/module/es5/tests/unit/Validate/isDouble.test.d.ts +0 -1
  314. package/module/es5/tests/unit/Validate/isDouble.test.js +0 -47
  315. package/module/es5/tests/unit/Validate/isEqual.test.d.ts +0 -1
  316. package/module/es5/tests/unit/Validate/isEqual.test.js +0 -74
  317. package/module/es5/tests/unit/Validate/isNotEmpty.test.d.ts +0 -1
  318. package/module/es5/tests/unit/Validate/isNotEmpty.test.js +0 -43
  319. package/module/es5/tests/unit/Validate/isNumber.test.d.ts +0 -1
  320. package/module/es5/tests/unit/Validate/isNumber.test.js +0 -77
  321. package/module/es5/tests/unit/Validate/isPerfectSquare.test.d.ts +0 -1
  322. package/module/es5/tests/unit/Validate/isPerfectSquare.test.js +0 -27
  323. package/module/es5/tests/unit/Validate/isPrimeNumber.test.d.ts +0 -1
  324. package/module/es5/tests/unit/Validate/isPrimeNumber.test.js +0 -51
  325. package/module/es5/tests/unit/Validate/isValueNaN.test.d.ts +0 -1
  326. package/module/es5/tests/unit/Validate/isValueNaN.test.js +0 -54
  327. package/module/es5/tests/unit/Validate/number/core.test.d.ts +0 -1
  328. package/module/es5/tests/unit/Validate/number/core.test.js +0 -36
  329. package/module/es5/tests/unit/Validate/number/double.test.d.ts +0 -1
  330. package/module/es5/tests/unit/Validate/number/double.test.js +0 -23
  331. package/module/es5/tests/unit/Validate/number/even.test.d.ts +0 -1
  332. package/module/es5/tests/unit/Validate/number/even.test.js +0 -23
  333. package/module/es5/tests/unit/Validate/number/maxValue.test.d.ts +0 -1
  334. package/module/es5/tests/unit/Validate/number/maxValue.test.js +0 -20
  335. package/module/es5/tests/unit/Validate/number/minValue.test.d.ts +0 -1
  336. package/module/es5/tests/unit/Validate/number/minValue.test.js +0 -20
  337. package/module/es5/tests/unit/Validate/number/odd.test.d.ts +0 -1
  338. package/module/es5/tests/unit/Validate/number/odd.test.js +0 -23
  339. package/module/es5/tests/unit/Validate/number/prime.test.d.ts +0 -1
  340. package/module/es5/tests/unit/Validate/number/prime.test.js +0 -25
  341. package/module/es5/tests/unit/Validate/object/core.test.d.ts +0 -1
  342. package/module/es5/tests/unit/Validate/object/core.test.js +0 -79
  343. package/module/es5/tests/unit/Validate/string/core.test.d.ts +0 -1
  344. package/module/es5/tests/unit/Validate/string/core.test.js +0 -27
  345. package/module/es5/tests/unit/Validate/string/email.test.d.ts +0 -1
  346. package/module/es5/tests/unit/Validate/string/email.test.js +0 -21
  347. package/module/es5/tests/unit/Validate/string/length.test.d.ts +0 -1
  348. package/module/es5/tests/unit/Validate/string/length.test.js +0 -18
  349. package/module/es5/tests/unit/Validate/string/maxLength.test.d.ts +0 -1
  350. package/module/es5/tests/unit/Validate/string/maxLength.test.js +0 -18
  351. package/module/es5/tests/unit/Validate/string/minLength.test.d.ts +0 -1
  352. package/module/es5/tests/unit/Validate/string/minLength.test.js +0 -18
  353. package/module/es5/tests/unit/Validate/string/numberString.test.d.ts +0 -1
  354. package/module/es5/tests/unit/Validate/string/numberString.test.js +0 -22
  355. package/module/es5/tests/unit/Validate/string/regexMatch.test.d.ts +0 -1
  356. package/module/es5/tests/unit/Validate/string/regexMatch.test.js +0 -29
  357. package/module/es5/tests/unit/Validate/string/uuid.test.d.ts +0 -1
  358. package/module/es5/tests/unit/Validate/string/uuid.test.js +0 -72
  359. package/module/es5/tests/unit/types/arrayType.test.d.ts +0 -1
  360. package/module/es5/tests/unit/types/arrayType.test.js +0 -11
  361. package/module/es5/tests/unit/types/clockType.test.d.ts +0 -1
  362. package/module/es5/tests/unit/types/clockType.test.js +0 -37
@@ -1,7 +1,9 @@
1
1
  export const chunk = (array, n) => {
2
- const result = [];
3
- for (let index = 0; index < array.length; index += n) {
4
- result.push(array.slice(index, index + n));
2
+ const length = array.length;
3
+ // eslint-disable-next-line unicorn/no-new-array
4
+ const result = new Array(Math.ceil(length / n));
5
+ for (let index = 0, k = 0; index < length; index += n, k++) {
6
+ result[k] = array.slice(index, index + n);
5
7
  }
6
8
  return result;
7
9
  };
@@ -1 +1 @@
1
- {"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../src/Array/chunk.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,KAAQ,EACR,CAAI,EACkB,EAAE;IACxB,MAAM,MAAM,GAAU,EAAE,CAAC;IACzB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACrD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAmB,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,MAA8B,CAAC;AACxC,CAAC,CAAC"}
1
+ {"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../src/Array/chunk.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,KAAQ,EACR,CAAI,EACkB,EAAE;IACxB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,gDAAgD;IAChD,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IAEhD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3D,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAmB,CAAC;IAC9D,CAAC;IAED,OAAO,MAA8B,CAAC;AACxC,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- type CompareFunction<T> = (a: T, b: T) => number;
1
+ import type { CompareFunction } from "../types/array/compareFunction";
2
2
  /**
3
3
  * Sort array using dual-pivot quicksort algorithm
4
4
  * More efficient than traditional quicksort for arrays with many duplicate values
@@ -13,4 +13,3 @@ type CompareFunction<T> = (a: T, b: T) => number;
13
13
  * dualPivotQuickSort(['banana', 'apple', 'orange']); // ['apple', 'banana', 'orange']
14
14
  */
15
15
  export declare const dualPivotQuickSort: <T>(array: T[], compareFunction?: CompareFunction<T>, startIndex?: number, endIndex?: number, insertionSortThreshold?: number) => T[];
16
- export {};
@@ -1,4 +1,6 @@
1
1
  import { compareFunctionDefault } from "./compareFunctionDefault";
2
+ import { applyInsertionSortIfNeeded } from "./sortingHelpers/applyInsertionSortIfNeeded";
3
+ import { validateRange } from "./sortingHelpers/rangeValidator";
2
4
  /**
3
5
  * Get the median of three elements in the array
4
6
  * @param array - The input array
@@ -83,24 +85,6 @@ const partition = (array, low, high, compareFunction) => {
83
85
  [array[high], array[right]] = [array[right], array[high]];
84
86
  return { leftPivotIndex: left, rightPivotIndex: right };
85
87
  };
86
- /**
87
- * Sort small arrays using selection sort
88
- * @param array - Array to be sorted
89
- * @param start - Starting index
90
- * @param end - Ending index
91
- * @param compareFunction - Comparison function
92
- */
93
- const insertionSort = (array, start, end, compareFunction) => {
94
- for (let index = start + 1; index <= end; index++) {
95
- const current = array[index];
96
- let index_ = index - 1;
97
- while (index_ >= start && compareFunction(array[index_], current) > 0) {
98
- array[index_ + 1] = array[index_];
99
- index_--;
100
- }
101
- array[index_ + 1] = current;
102
- }
103
- };
104
88
  /**
105
89
  * Internal implementation of dual-pivot quicksort
106
90
  * @param array - Array to be sorted
@@ -110,9 +94,7 @@ const insertionSort = (array, start, end, compareFunction) => {
110
94
  * @param insertionSortThreshold - Threshold for switching to insertion sort
111
95
  */
112
96
  const sortRange = (array, start, end, compareFunction, insertionSortThreshold) => {
113
- // Use insertion sort for small arrays
114
- if (end - start + 1 <= insertionSortThreshold) {
115
- insertionSort(array, start, end, compareFunction);
97
+ if (applyInsertionSortIfNeeded(array, start, end, compareFunction, insertionSortThreshold)) {
116
98
  return;
117
99
  }
118
100
  // Get partition indices
@@ -140,11 +122,8 @@ const sortRange = (array, start, end, compareFunction, insertionSortThreshold) =
140
122
  * dualPivotQuickSort(['banana', 'apple', 'orange']); // ['apple', 'banana', 'orange']
141
123
  */
142
124
  export const dualPivotQuickSort = (array, compareFunction = (compareFunctionDefault), startIndex = 0, endIndex = array.length - 1, insertionSortThreshold = 10) => {
143
- // Validate and adjust indices
144
- const validStartIndex = Math.max(0, Math.min(startIndex, array.length - 1));
145
- const validEndIndex = Math.max(validStartIndex, Math.min(endIndex, array.length - 1));
146
- // Sort array if valid range exists
147
- if (validEndIndex >= validStartIndex) {
125
+ const { startIndex: validStartIndex, endIndex: validEndIndex, shouldSort, } = validateRange(array, startIndex, endIndex);
126
+ if (shouldSort) {
148
127
  sortRange(array, validStartIndex, validEndIndex, compareFunction, insertionSortThreshold);
149
128
  }
150
129
  return array;
@@ -1 +1 @@
1
- {"version":3,"file":"dualPivotQuickSort.js","sourceRoot":"","sources":["../../src/Array/dualPivotQuickSort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AASlE;;;;;;;;GAQG;AACH,MAAM,aAAa,GAAG,CACpB,KAAU,EACV,CAAS,EACT,CAAS,EACT,CAAS,EACT,eAAmC,EAC3B,EAAE;IACV,uCAAuC;IACvC,MAAM,MAAM,GAAG;QACb,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE;QAC7B,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE;QAC7B,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE;KAC9B,CAAC;IAEF,6CAA6C;IAC7C,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACzD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACzB,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,SAAS,GAAG,CAChB,KAAU,EACV,GAAW,EACX,I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ACzC,SAAS,CACP,KAAK,EACL,cAAc,GAAG,CAAC,EAClB,eAAe,GAAG,CAAC,EACnB,eAAe,EACf,sBAAsB,CACvB,CAAC;IACJ,CAAC;IAED,uBAAuB;IACvB,SAAS,CACP,KAAK,EACL,eAAe,GAAG,CAAC,EACnB,GAAG,EACH,eAAe,EACf,sBAAsB,CACvB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAAU,EACV,kBAAsC,CAAA,sBAAyB,CAAA,EAC/D,UAAU,GAAG,CAAC,EACd,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAC3B,sBAAsB,GAAG,EAAE,EACtB,EAAE;IACP,MAAM,EACJ,UAAU,EAAE,eAAe,EAC3B,QAAQ,EAAE,aAAa,EACvB,UAAU,GACX,GAAG,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAE/C,IAAI,UAAU,EAAE,CAAC;QACf,SAAS,CACP,KAAK,EACL,eAAe,EACf,aAAa,EACb,eAAe,EACf,sBAAsB,CACvB,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
@@ -1,4 +1,6 @@
1
1
  import { compareFunctionDefault } from "./compareFunctionDefault";
2
+ import { applyInsertionSortIfNeeded } from "./sortingHelpers/applyInsertionSortIfNeeded";
3
+ import { validateRange } from "./sortingHelpers/rangeValidator";
2
4
  /**
3
5
  * Finds the median value among three elements in the array
4
6
  * @param array The array containing the elements
@@ -54,25 +56,6 @@ const partition = (array, low, high, compareFunction) => {
54
56
  [array[left], array[right]] = [array[right], array[left]];
55
57
  }
56
58
  };
57
- /**
58
- * Sorts a portion of the array using insertion sort algorithm
59
- * @param array Array to sort
60
- * @param low Starting index of the range to sort
61
- * @param high Ending index of the range to sort
62
- * @param compareFunction Function to compare elements
63
- */
64
- const insertionSort = (array, low, high, compareFunction) => {
65
- for (let index = low + 1; index <= high; index++) {
66
- const key = array[index];
67
- let currentIndex = index - 1;
68
- while (currentIndex >= low &&
69
- compareFunction(array[currentIndex], key) > 0) {
70
- array[currentIndex + 1] = array[currentIndex];
71
- currentIndex--;
72
- }
73
- array[currentIndex + 1] = key;
74
- }
75
- };
76
59
  /**
77
60
  * Internal implementation of the quicksort algorithm with tail-call optimization
78
61
  * @param array Array to sort
@@ -85,8 +68,7 @@ const sortImpl = (array, lowInit, highInit, compareFunction, insertionSortThresh
85
68
  let low = lowInit;
86
69
  let high = highInit;
87
70
  while (low < high) {
88
- if (high - low < insertionSortThreshold) {
89
- insertionSort(array, low, high, compareFunction);
71
+ if (applyInsertionSortIfNeeded(array, low, high, compareFunction, insertionSortThreshold)) {
90
72
  return;
91
73
  }
92
74
  const pivotIndex = partition(array, low, high, compareFunction);
@@ -114,10 +96,10 @@ const sortImpl = (array, lowInit, highInit, compareFunction, insertionSortThresh
114
96
  * quickSort(['b', 'a', 'c']); // ['a', 'b', 'c']
115
97
  */
116
98
  export const quickSort = (array, compareFunction = (compareFunctionDefault), startIndex = 0, endIndex = array.length - 1, insertionSortThreshold = 10) => {
117
- // Only sort within valid range
118
- const validStartIndex = Math.max(0, Math.min(startIndex, array.length - 1));
119
- const validEndIndex = Math.max(validStartIndex, Math.min(endIndex, array.length - 1));
120
- sortImpl(array, validStartIndex, validEndIndex, compareFunction, insertionSortThreshold);
99
+ const { startIndex: validStartIndex, endIndex: validEndIndex, shouldSort, } = validateRange(array, startIndex, endIndex);
100
+ if (shouldSort) {
101
+ sortImpl(array, validStartIndex, validEndIndex, compareFunction, insertionSortThreshold);
102
+ }
121
103
  return array;
122
104
  };
123
105
  //# sourceMappingURL=quickSort.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"quickSort.js","sourceRoot":"","sources":["../../src/Array/quickSort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAIlE;;;;;;;;GAQG;AACH,MAAM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,EAAE,eAAe,EAC3B,QAAQ,EAAE,aAAa,EACvB,UAAU,GACX,GAAG,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAE/C,IAAI,UAAU,EAAE,CAAC;QACf,QAAQ,CACN,KAAK,EACL,eAAe,EACf,aAAa,EACb,eAAe,EACf,sBAAsB,CACvB,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { CompareFunction } from "../../types/array/compareFunction";
2
+ /**
3
+ * Checks if a partition is small enough to apply insertion sort and applies it if so.
4
+ *
5
+ * @template T The type of elements in the array.
6
+ * @param {T[]} array The array containing the partition.
7
+ * @param {number} low The starting index of the partition.
8
+ * @param {number} high The ending index of the partition.
9
+ * @param {CompareFunction<T>} compareFunction The function to compare elements.
10
+ * @param {number} insertionSortThreshold The size threshold for switching to insertion sort.
11
+ * @returns {boolean} True if insertion sort was applied, false otherwise.
12
+ */
13
+ export declare const applyInsertionSortIfNeeded: <T>(array: T[], low: number, high: number, compareFunction: CompareFunction<T>, insertionSortThreshold: number) => boolean;
@@ -0,0 +1,20 @@
1
+ import { insertionSort } from "../../Array/insertionSort";
2
+ /**
3
+ * Checks if a partition is small enough to apply insertion sort and applies it if so.
4
+ *
5
+ * @template T The type of elements in the array.
6
+ * @param {T[]} array The array containing the partition.
7
+ * @param {number} low The starting index of the partition.
8
+ * @param {number} high The ending index of the partition.
9
+ * @param {CompareFunction<T>} compareFunction The function to compare elements.
10
+ * @param {number} insertionSortThreshold The size threshold for switching to insertion sort.
11
+ * @returns {boolean} True if insertion sort was applied, false otherwise.
12
+ */
13
+ export const applyInsertionSortIfNeeded = (array, low, high, compareFunction, insertionSortThreshold) => {
14
+ if (high - low + 1 <= insertionSortThreshold) {
15
+ insertionSort(array, compareFunction, low, high);
16
+ return true;
17
+ }
18
+ return false;
19
+ };
20
+ //# sourceMappingURL=applyInsertionSortIfNeeded.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyInsertionSortIfNeeded.js","sourceRoot":"","sources":["../../../src/Array/sortingHelpers/applyInsertionSortIfNeeded.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,KAAU,EACV,GAAW,EACX,IAAY,EACZ,eAAmC,EACnC,sBAA8B,EACrB,EAAE;IACX,IAAI,IAAI,GAAG,GAAG,GAAG,CAAC,IAAI,sBAAsB,EAAE,CAAC;QAC7C,aAAa,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ export interface ValidatedSortRange {
2
+ startIndex: number;
3
+ endIndex: number;
4
+ shouldSort: boolean;
5
+ }
6
+ /**
7
+ * Validates and adjusts the start and end indices for an operation on an array.
8
+ * Ensures indices are within the bounds of the array.
9
+ *
10
+ * @template T The type of elements in the array.
11
+ * @param {T[]} array The array.
12
+ * @param {number} startIndex The desired starting index.
13
+ * @param {number} endIndex The desired ending index.
14
+ * @returns {ValidatedSortRange} An object containing the validated start index, end index,
15
+ * and a boolean indicating if the operation should proceed on the range.
16
+ */
17
+ export declare const validateRange: <T>(array: T[], startIndex: number, endIndex: number) => ValidatedSortRange;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Validates and adjusts the start and end indices for an operation on an array.
3
+ * Ensures indices are within the bounds of the array.
4
+ *
5
+ * @template T The type of elements in the array.
6
+ * @param {T[]} array The array.
7
+ * @param {number} startIndex The desired starting index.
8
+ * @param {number} endIndex The desired ending index.
9
+ * @returns {ValidatedSortRange} An object containing the validated start index, end index,
10
+ * and a boolean indicating if the operation should proceed on the range.
11
+ */
12
+ export const validateRange = (array, startIndex, endIndex) => {
13
+ const length = array.length;
14
+ // Handle empty arrays early
15
+ if (length === 0) {
16
+ return { startIndex: 0, endIndex: -1, shouldSort: false };
17
+ }
18
+ const validatedStartIndex = Math.max(0, Math.min(startIndex, length - 1));
19
+ const validatedEndIndex = Math.max(validatedStartIndex, Math.min(endIndex, length - 1));
20
+ return {
21
+ startIndex: validatedStartIndex,
22
+ endIndex: validatedEndIndex,
23
+ shouldSort: validatedEndIndex >= validatedStartIndex,
24
+ };
25
+ };
26
+ //# sourceMappingURL=rangeValidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rangeValidator.js","sourceRoot":"","sources":["../../../src/Array/sortingHelpers/rangeValidator.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAU,EACV,UAAkB,EAClB,QAAgB,EACI,EAAE;IACtB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,4BAA4B;IAC5B,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;QACjB,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAC5D,CAAC;IAED,MAAM,mBAAmB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IAC1E,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAChC,mBAAmB,EACnB,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,CAC/B,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,mBAAmB;QAC/B,QAAQ,EAAE,iBAAiB;QAC3B,UAAU,EAAE,iBAAiB,IAAI,mBAAmB;KACrD,CAAC;AACJ,CAAC,CAAC"}
@@ -2,7 +2,7 @@
2
2
  * Object validation core module
3
3
  * Provides validation functionality for objects with type-specific validation rules for each property
4
4
  */
5
- import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
5
+ import type { Types, ValidateCoreReturnType, ValidateType } from "../../Validate/type";
6
6
  /**
7
7
  * Creates an object validator with property-specific validation rules
8
8
  * @template T - Object type containing validation functions for each property
@@ -12,8 +12,4 @@ import type { ValidateCoreReturnType, ValidateType } from "../../Validate/type";
12
12
  */
13
13
  export declare const object: <T extends {
14
14
  [key: string]: (value: any) => ValidateCoreReturnType<any>;
15
- }>(option?: T, message?: string) => (value: { [key in keyof T]: ValidateType<ReturnType<T[key]>["type"]>; }) => {
16
- validate: boolean;
17
- message: string;
18
- type: { [key in keyof T]: ValidateType<ReturnType<T[key]>["type"]>; };
19
- };
15
+ }>(option?: T, message?: string) => (value: Types<{ [key in keyof T]: ValidateType<ReturnType<T[key]>["type"]>; }>) => ValidateCoreReturnType<{ [key in keyof T]: ValidateType<ReturnType<T[key]>["type"]>; }>;
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/object/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAMpB,SAAY,EAAO,EACnB,OAAgB,EAChB,EAAE;IACF,OAAO,CACL,KAEC,EAKD,EAAE;QACF,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,QAAQ,IAAI,MAAM,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;gBAChD,OAAO;oBACL,QAAQ,EAAE,KAAK;oBACf,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO;oBACxC,IAAI,EAAE,KAAK;iBACZ,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/Validate/object/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAOnE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAMpB,SAAY,EAAO,EACnB,OAAgB,EAChB,EAAE;IACF,OAAO,CACL,KAEE,EAGD,EAAE;QACH,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,OAAO,IAAI,EAAE;gBACtB,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,QAAQ,IAAI,MAAM,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;gBAChD,OAAO;oBACL,QAAQ,EAAE,KAAK;oBACf,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO;oBACxC,IAAI,EAAE,KAAK;iBACZ,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,KAAK;SACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -33,3 +33,4 @@ export type ValidateFunctionType<T> = (value: T) => boolean;
33
33
  * @returns The corresponding TypeScript type (string, number, boolean) or the original type T
34
34
  */
35
35
  export type ValidateType<T> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T;
36
+ export type SchemaToInterface<T extends (value: any) => ValidateCoreReturnType<any>> = ReturnType<T>["type"];
@@ -12,9 +12,11 @@ exports.chunk = void 0;
12
12
  * @example chunk([1, 2, 3, 4, 5, 6, 7, 8, 9], 3); // [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
13
13
  */
14
14
  var chunk = exports.chunk = function chunk(array, n) {
15
- var result = [];
16
- for (var index = 0; index < array.length; index += n) {
17
- result.push(array.slice(index, index + n));
15
+ var length = array.length;
16
+ // eslint-disable-next-line unicorn/no-new-array
17
+ var result = new Array(Math.ceil(length / n));
18
+ for (var index = 0, k = 0; index < length; index += n, k++) {
19
+ result[k] = array.slice(index, index + n);
18
20
  }
19
21
  return result;
20
22
  };
@@ -1,4 +1,4 @@
1
- type CompareFunction<T> = (a: T, b: T) => number;
1
+ import type { CompareFunction } from "$/array/compareFunction";
2
2
  /**
3
3
  * Sort array using dual-pivot quicksort algorithm
4
4
  * More efficient than traditional quicksort for arrays with many duplicate values
@@ -13,4 +13,3 @@ type CompareFunction<T> = (a: T, b: T) => number;
13
13
  * dualPivotQuickSort(['banana', 'apple', 'orange']); // ['apple', 'banana', 'orange']
14
14
  */
15
15
  export declare const dualPivotQuickSort: <T>(array: T[], compareFunction?: CompareFunction<T>, startIndex?: number, endIndex?: number, insertionSortThreshold?: number) => T[];
16
- export {};
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.dualPivotQuickSort = void 0;
7
7
  var _compareFunctionDefault = require("./compareFunctionDefault");
8
+ var _applyInsertionSortIfNeeded = require("./sortingHelpers/applyInsertionSortIfNeeded");
9
+ var _rangeValidator = require("./sortingHelpers/rangeValidator");
8
10
  /**
9
11
  * Get the median of three elements in the array
10
12
  * @param array - The input array
@@ -120,25 +122,6 @@ var partition = function partition(array, low, high, compareFunction) {
120
122
  };
121
123
  };
122
124
 
123
- /**
124
- * Sort small arrays using selection sort
125
- * @param array - Array to be sorted
126
- * @param start - Starting index
127
- * @param end - Ending index
128
- * @param compareFunction - Comparison function
129
- */
130
- var insertionSort = function insertionSort(array, start, end, compareFunction) {
131
- for (var index = start + 1; index <= end; index++) {
132
- var current = array[index];
133
- var index_ = index - 1;
134
- while (index_ >= start && compareFunction(array[index_], current) > 0) {
135
- array[index_ + 1] = array[index_];
136
- index_--;
137
- }
138
- array[index_ + 1] = current;
139
- }
140
- };
141
-
142
125
  /**
143
126
  * Internal implementation of dual-pivot quicksort
144
127
  * @param array - Array to be sorted
@@ -148,9 +131,7 @@ var insertionSort = function insertionSort(array, start, end, compareFunction) {
148
131
  * @param insertionSortThreshold - Threshold for switching to insertion sort
149
132
  */
150
133
  var _sortRange = function sortRange(array, start, end, compareFunction, insertionSortThreshold) {
151
- // Use insertion sort for small arrays
152
- if (end - start + 1 <= insertionSortThreshold) {
153
- insertionSort(array, start, end, compareFunction);
134
+ if ((0, _applyInsertionSortIfNeeded.applyInsertionSortIfNeeded)(array, start, end, compareFunction, insertionSortThreshold)) {
154
135
  return;
155
136
  }
156
137
 
@@ -189,12 +170,11 @@ var dualPivotQuickSort = exports.dualPivotQuickSort = function dualPivotQuickSor
189
170
  var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
190
171
  var endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : array.length - 1;
191
172
  var insertionSortThreshold = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 10;
192
- // Validate and adjust indices
193
- var validStartIndex = Math.max(0, Math.min(startIndex, array.length - 1));
194
- var validEndIndex = Math.max(validStartIndex, Math.min(endIndex, array.length - 1));
195
-
196
- // Sort array if valid range exists
197
- if (validEndIndex >= validStartIndex) {
173
+ var _validateRange = (0, _rangeValidator.validateRange)(array, startIndex, endIndex),
174
+ validStartIndex = _validateRange.startIndex,
175
+ validEndIndex = _validateRange.endIndex,
176
+ shouldSort = _validateRange.shouldSort;
177
+ if (shouldSort) {
198
178
  _sortRange(array, validStartIndex, validEndIndex, compareFunction, insertionSortThreshold);
199
179
  }
200
180
  return array;
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.quickSort = void 0;
7
7
  var _compareFunctionDefault = require("./compareFunctionDefault");
8
+ var _applyInsertionSortIfNeeded = require("./sortingHelpers/applyInsertionSortIfNeeded");
9
+ var _rangeValidator = require("./sortingHelpers/rangeValidator");
8
10
  /**
9
11
  * Finds the median value among three elements in the array
10
12
  * @param array The array containing the elements
@@ -64,25 +66,6 @@ var partition = function partition(array, low, high, compareFunction) {
64
66
  }
65
67
  };
66
68
 
67
- /**
68
- * Sorts a portion of the array using insertion sort algorithm
69
- * @param array Array to sort
70
- * @param low Starting index of the range to sort
71
- * @param high Ending index of the range to sort
72
- * @param compareFunction Function to compare elements
73
- */
74
- var insertionSort = function insertionSort(array, low, high, compareFunction) {
75
- for (var index = low + 1; index <= high; index++) {
76
- var key = array[index];
77
- var currentIndex = index - 1;
78
- while (currentIndex >= low && compareFunction(array[currentIndex], key) > 0) {
79
- array[currentIndex + 1] = array[currentIndex];
80
- currentIndex--;
81
- }
82
- array[currentIndex + 1] = key;
83
- }
84
- };
85
-
86
69
  /**
87
70
  * Internal implementation of the quicksort algorithm with tail-call optimization
88
71
  * @param array Array to sort
@@ -95,8 +78,7 @@ var _sortImpl = function sortImpl(array, lowInit, highInit, compareFunction, ins
95
78
  var low = lowInit;
96
79
  var high = highInit;
97
80
  while (low < high) {
98
- if (high - low < insertionSortThreshold) {
99
- insertionSort(array, low, high, compareFunction);
81
+ if ((0, _applyInsertionSortIfNeeded.applyInsertionSortIfNeeded)(array, low, high, compareFunction, insertionSortThreshold)) {
100
82
  return;
101
83
  }
102
84
  var pivotIndex = partition(array, low, high, compareFunction);
@@ -128,9 +110,12 @@ var quickSort = exports.quickSort = function quickSort(array) {
128
110
  var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
129
111
  var endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : array.length - 1;
130
112
  var insertionSortThreshold = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 10;
131
- // Only sort within valid range
132
- var validStartIndex = Math.max(0, Math.min(startIndex, array.length - 1));
133
- var validEndIndex = Math.max(validStartIndex, Math.min(endIndex, array.length - 1));
134
- _sortImpl(array, validStartIndex, validEndIndex, compareFunction, insertionSortThreshold);
113
+ var _validateRange = (0, _rangeValidator.validateRange)(array, startIndex, endIndex),
114
+ validStartIndex = _validateRange.startIndex,
115
+ validEndIndex = _validateRange.endIndex,
116
+ shouldSort = _validateRange.shouldSort;
117
+ if (shouldSort) {
118
+ _sortImpl(array, validStartIndex, validEndIndex, compareFunction, insertionSortThreshold);
119
+ }
135
120
  return array;
136
121
  };
@@ -0,0 +1,13 @@
1
+ import type { CompareFunction } from "$/array/compareFunction";
2
+ /**
3
+ * Checks if a partition is small enough to apply insertion sort and applies it if so.
4
+ *
5
+ * @template T The type of elements in the array.
6
+ * @param {T[]} array The array containing the partition.
7
+ * @param {number} low The starting index of the partition.
8
+ * @param {number} high The ending index of the partition.
9
+ * @param {CompareFunction<T>} compareFunction The function to compare elements.
10
+ * @param {number} insertionSortThreshold The size threshold for switching to insertion sort.
11
+ * @returns {boolean} True if insertion sort was applied, false otherwise.
12
+ */
13
+ export declare const applyInsertionSortIfNeeded: <T>(array: T[], low: number, high: number, compareFunction: CompareFunction<T>, insertionSortThreshold: number) => boolean;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.applyInsertionSortIfNeeded = void 0;
7
+ var _insertionSort = require("@/Array/insertionSort");
8
+ /**
9
+ * Checks if a partition is small enough to apply insertion sort and applies it if so.
10
+ *
11
+ * @template T The type of elements in the array.
12
+ * @param {T[]} array The array containing the partition.
13
+ * @param {number} low The starting index of the partition.
14
+ * @param {number} high The ending index of the partition.
15
+ * @param {CompareFunction<T>} compareFunction The function to compare elements.
16
+ * @param {number} insertionSortThreshold The size threshold for switching to insertion sort.
17
+ * @returns {boolean} True if insertion sort was applied, false otherwise.
18
+ */
19
+ var applyInsertionSortIfNeeded = exports.applyInsertionSortIfNeeded = function applyInsertionSortIfNeeded(array, low, high, compareFunction, insertionSortThreshold) {
20
+ if (high - low + 1 <= insertionSortThreshold) {
21
+ (0, _insertionSort.insertionSort)(array, compareFunction, low, high);
22
+ return true;
23
+ }
24
+ return false;
25
+ };
@@ -0,0 +1,17 @@
1
+ export interface ValidatedSortRange {
2
+ startIndex: number;
3
+ endIndex: number;
4
+ shouldSort: boolean;
5
+ }
6
+ /**
7
+ * Validates and adjusts the start and end indices for an operation on an array.
8
+ * Ensures indices are within the bounds of the array.
9
+ *
10
+ * @template T The type of elements in the array.
11
+ * @param {T[]} array The array.
12
+ * @param {number} startIndex The desired starting index.
13
+ * @param {number} endIndex The desired ending index.
14
+ * @returns {ValidatedSortRange} An object containing the validated start index, end index,
15
+ * and a boolean indicating if the operation should proceed on the range.
16
+ */
17
+ export declare const validateRange: <T>(array: T[], startIndex: number, endIndex: number) => ValidatedSortRange;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateRange = void 0;
7
+ /**
8
+ * Validates and adjusts the start and end indices for an operation on an array.
9
+ * Ensures indices are within the bounds of the array.
10
+ *
11
+ * @template T The type of elements in the array.
12
+ * @param {T[]} array The array.
13
+ * @param {number} startIndex The desired starting index.
14
+ * @param {number} endIndex The desired ending index.
15
+ * @returns {ValidatedSortRange} An object containing the validated start index, end index,
16
+ * and a boolean indicating if the operation should proceed on the range.
17
+ */
18
+ var validateRange = exports.validateRange = function validateRange(array, startIndex, endIndex) {
19
+ var length = array.length;
20
+ // Handle empty arrays early
21
+ if (length === 0) {
22
+ return {
23
+ startIndex: 0,
24
+ endIndex: -1,
25
+ shouldSort: false
26
+ };
27
+ }
28
+ var validatedStartIndex = Math.max(0, Math.min(startIndex, length - 1));
29
+ var validatedEndIndex = Math.max(validatedStartIndex, Math.min(endIndex, length - 1));
30
+ return {
31
+ startIndex: validatedStartIndex,
32
+ endIndex: validatedEndIndex,
33
+ shouldSort: validatedEndIndex >= validatedStartIndex
34
+ };
35
+ };
@@ -2,7 +2,7 @@
2
2
  * Object validation core module
3
3
  * Provides validation functionality for objects with type-specific validation rules for each property
4
4
  */
5
- import type { ValidateCoreReturnType, ValidateType } from "@/Validate/type";
5
+ import type { Types, ValidateCoreReturnType, ValidateType } from "@/Validate/type";
6
6
  /**
7
7
  * Creates an object validator with property-specific validation rules
8
8
  * @template T - Object type containing validation functions for each property
@@ -12,8 +12,4 @@ import type { ValidateCoreReturnType, ValidateType } from "@/Validate/type";
12
12
  */
13
13
  export declare const object: <T extends {
14
14
  [key: string]: (value: any) => ValidateCoreReturnType<any>;
15
- }>(option?: T, message?: string) => (value: { [key in keyof T]: ValidateType<ReturnType<T[key]>["type"]>; }) => {
16
- validate: boolean;
17
- message: string;
18
- type: { [key in keyof T]: ValidateType<ReturnType<T[key]>["type"]>; };
19
- };
15
+ }>(option?: T, message?: string) => (value: Types<{ [key in keyof T]: ValidateType<ReturnType<T[key]>["type"]>; }>) => ValidateCoreReturnType<{ [key in keyof T]: ValidateType<ReturnType<T[key]>["type"]>; }>;
@@ -33,3 +33,4 @@ export type ValidateFunctionType<T> = (value: T) => boolean;
33
33
  * @returns The corresponding TypeScript type (string, number, boolean) or the original type T
34
34
  */
35
35
  export type ValidateType<T> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T;
36
+ export type SchemaToInterface<T extends (value: any) => ValidateCoreReturnType<any>> = ReturnType<T>["type"];