@valkey/valkey-glide-darwin-arm64 1.2.0 → 1.2.1-rc0

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 (439) hide show
  1. package/build-ts/src/BaseClient.d.ts +27 -1
  2. package/build-ts/src/BaseClient.js +9 -1
  3. package/build-ts/src/BaseClient.js.map +1 -1
  4. package/build-ts/src/Commands.d.ts +12 -0
  5. package/build-ts/src/Commands.js.map +1 -1
  6. package/build-ts/src/GlideClient.d.ts +17 -1
  7. package/build-ts/src/GlideClient.js +3 -0
  8. package/build-ts/src/GlideClient.js.map +1 -1
  9. package/build-ts/src/GlideClusterClient.d.ts +23 -7
  10. package/build-ts/src/GlideClusterClient.js +8 -3
  11. package/build-ts/src/GlideClusterClient.js.map +1 -1
  12. package/build-ts/src/ProtobufMessage.js +46 -1
  13. package/build-ts/src/ProtobufMessage.js.map +1 -1
  14. package/node_modules/glide-rs/glide-rs.darwin-arm64.node +0 -0
  15. package/node_modules/glide-rs/index.d.ts +2 -1
  16. package/node_modules/glide-rs/index.js +4 -2
  17. package/npm/glide/index.ts +4 -3
  18. package/npm/glide/package.json +0 -1
  19. package/package.json +2 -2
  20. package/rust-client/node_modules/mingo/README.md +58 -53
  21. package/rust-client/node_modules/mingo/dist/cjs/aggregator.js +18 -20
  22. package/rust-client/node_modules/mingo/dist/cjs/core.js +179 -190
  23. package/rust-client/node_modules/mingo/dist/cjs/cursor.js +34 -34
  24. package/rust-client/node_modules/mingo/dist/cjs/index.js +11 -3
  25. package/rust-client/node_modules/mingo/dist/cjs/init/basic.js +4 -22
  26. package/rust-client/node_modules/mingo/dist/cjs/init/system.js +6 -6
  27. package/rust-client/node_modules/mingo/dist/cjs/lazy.js +58 -61
  28. package/rust-client/node_modules/mingo/dist/cjs/operators/_predicates.js +12 -25
  29. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/_internal.js +2 -4
  30. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/accumulator.js +1 -2
  31. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/first.js +3 -1
  32. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/last.js +4 -1
  33. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/max.js +9 -6
  34. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/mergeObjects.js +5 -1
  35. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/min.js +9 -3
  36. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/push.js +1 -2
  37. package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/sum.js +2 -4
  38. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/add.js +9 -10
  39. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/ceil.js +1 -2
  40. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/exp.js +1 -2
  41. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/floor.js +1 -2
  42. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/ln.js +1 -2
  43. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/log.js +1 -2
  44. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/log10.js +1 -2
  45. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/round.js +1 -2
  46. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/sqrt.js +1 -2
  47. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/subtract.js +5 -2
  48. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/trunc.js +1 -2
  49. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/arrayElemAt.js +2 -3
  50. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/arrayToObject.js +3 -4
  51. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/concatArrays.js +11 -5
  52. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/filter.js +1 -0
  53. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/first.js +8 -8
  54. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/firstN.js +2 -4
  55. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/in.js +1 -1
  56. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/indexOfArray.js +5 -10
  57. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/isArray.js +2 -3
  58. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/last.js +8 -8
  59. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/lastN.js +2 -4
  60. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/map.js +1 -0
  61. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/maxN.js +2 -4
  62. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/minN.js +2 -4
  63. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/reduce.js +1 -2
  64. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/reverseArray.js +1 -2
  65. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/sortArray.js +2 -4
  66. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/zip.js +4 -10
  67. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/bitwise/_internal.js +1 -2
  68. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/bitwise/bitNot.js +2 -4
  69. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/boolean/not.js +3 -5
  70. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/comparison/cmp.js +6 -5
  71. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/cond.js +1 -1
  72. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/ifNull.js +1 -1
  73. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/switch.js +1 -2
  74. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/_internal.js +157 -65
  75. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateAdd.js +1 -29
  76. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateDiff.js +32 -20
  77. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateFromParts.js +2 -4
  78. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateFromString.js +13 -9
  79. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateToString.js +2 -4
  80. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateTrunc.js +107 -0
  81. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dayOfYear.js +1 -1
  82. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/index.js +2 -0
  83. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/isoWeekYear.js +1 -4
  84. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/week.js +1 -2
  85. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/misc/getField.js +1 -2
  86. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/mergeObjects.js +9 -2
  87. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/objectToArray.js +5 -1
  88. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/setField.js +11 -7
  89. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setDifference.js +9 -1
  90. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setEquals.js +17 -3
  91. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setIntersection.js +2 -1
  92. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setIsSubset.js +15 -1
  93. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setUnion.js +4 -5
  94. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/_internal.js +4 -8
  95. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/concat.js +5 -2
  96. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/indexOfBytes.js +2 -4
  97. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/replaceAll.js +1 -2
  98. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/replaceOne.js +1 -2
  99. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/split.js +1 -2
  100. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/strcasecmp.js +1 -2
  101. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/substr.js +4 -14
  102. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/substrBytes.js +2 -4
  103. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/trignometry/atan2.js +2 -4
  104. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/trignometry/cosh.js +0 -1
  105. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/_internal.js +20 -10
  106. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/convert.js +3 -5
  107. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toBool.js +2 -4
  108. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toDate.js +3 -6
  109. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toDouble.js +5 -10
  110. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toInt.js +1 -4
  111. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toLong.js +1 -4
  112. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toString.js +11 -10
  113. package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/type.js +11 -14
  114. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/addFields.js +1 -2
  115. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/bucket.js +53 -53
  116. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/bucketAuto.js +670 -65
  117. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/count.js +2 -2
  118. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/densify.js +196 -0
  119. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/graphLookup.js +78 -0
  120. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/group.js +6 -9
  121. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/index.js +4 -0
  122. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/limit.js +1 -3
  123. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/lookup.js +47 -10
  124. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/merge.js +7 -13
  125. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/out.js +1 -1
  126. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/project.js +19 -38
  127. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/redact.js +3 -1
  128. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/replaceWith.js +9 -2
  129. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sample.js +1 -2
  130. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/setWindowFields.js +10 -20
  131. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/skip.js +1 -1
  132. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sort.js +10 -19
  133. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sortByCount.js +5 -3
  134. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unionWith.js +1 -1
  135. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unset.js +1 -2
  136. package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unwind.js +5 -9
  137. package/rust-client/node_modules/mingo/dist/cjs/operators/projection/elemMatch.js +2 -3
  138. package/rust-client/node_modules/mingo/dist/cjs/operators/projection/slice.js +2 -3
  139. package/rust-client/node_modules/mingo/dist/cjs/operators/query/bitwise/_internal.js +4 -4
  140. package/rust-client/node_modules/mingo/dist/cjs/operators/update/_internal.js +8 -14
  141. package/rust-client/node_modules/mingo/dist/cjs/operators/update/addToSet.js +1 -2
  142. package/rust-client/node_modules/mingo/dist/cjs/operators/update/bit.js +1 -2
  143. package/rust-client/node_modules/mingo/dist/cjs/operators/update/max.js +1 -2
  144. package/rust-client/node_modules/mingo/dist/cjs/operators/update/min.js +1 -2
  145. package/rust-client/node_modules/mingo/dist/cjs/operators/update/pop.js +1 -2
  146. package/rust-client/node_modules/mingo/dist/cjs/operators/update/pull.js +2 -4
  147. package/rust-client/node_modules/mingo/dist/cjs/operators/update/push.js +3 -9
  148. package/rust-client/node_modules/mingo/dist/cjs/operators/update/rename.js +1 -2
  149. package/rust-client/node_modules/mingo/dist/cjs/operators/update/set.js +1 -2
  150. package/rust-client/node_modules/mingo/dist/cjs/operators/update/unset.js +1 -2
  151. package/rust-client/node_modules/mingo/dist/cjs/operators/window/_internal.js +2 -3
  152. package/rust-client/node_modules/mingo/dist/cjs/operators/window/denseRank.js +8 -10
  153. package/rust-client/node_modules/mingo/dist/cjs/operators/window/derivative.js +4 -6
  154. package/rust-client/node_modules/mingo/dist/cjs/operators/window/documentNumber.js +1 -3
  155. package/rust-client/node_modules/mingo/dist/cjs/operators/window/expMovingAvg.js +4 -6
  156. package/rust-client/node_modules/mingo/dist/cjs/operators/window/integral.js +3 -4
  157. package/rust-client/node_modules/mingo/dist/cjs/operators/window/linearFill.js +4 -6
  158. package/rust-client/node_modules/mingo/dist/cjs/operators/window/locf.js +3 -4
  159. package/rust-client/node_modules/mingo/dist/cjs/operators/window/rank.js +8 -10
  160. package/rust-client/node_modules/mingo/dist/cjs/operators/window/shift.js +2 -2
  161. package/rust-client/node_modules/mingo/dist/cjs/query.js +20 -19
  162. package/rust-client/node_modules/mingo/dist/cjs/types.js +22 -0
  163. package/rust-client/node_modules/mingo/dist/cjs/updater.js +6 -5
  164. package/rust-client/node_modules/mingo/dist/cjs/util.js +265 -388
  165. package/rust-client/node_modules/mingo/dist/esm/aggregator.js +18 -21
  166. package/rust-client/node_modules/mingo/dist/esm/core.js +179 -192
  167. package/rust-client/node_modules/mingo/dist/esm/cursor.js +35 -35
  168. package/rust-client/node_modules/mingo/dist/esm/index.js +8 -2
  169. package/rust-client/node_modules/mingo/dist/esm/init/basic.js +5 -12
  170. package/rust-client/node_modules/mingo/dist/esm/init/system.js +7 -7
  171. package/rust-client/node_modules/mingo/dist/esm/lazy.js +58 -61
  172. package/rust-client/node_modules/mingo/dist/esm/operators/_predicates.js +14 -32
  173. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/_internal.js +2 -4
  174. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/accumulator.js +1 -2
  175. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/first.js +7 -2
  176. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/last.js +8 -2
  177. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/max.js +10 -7
  178. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/mergeObjects.js +5 -1
  179. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/min.js +10 -4
  180. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/push.js +1 -2
  181. package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/sum.js +2 -4
  182. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/add.js +9 -10
  183. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/ceil.js +1 -2
  184. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/exp.js +1 -2
  185. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/floor.js +1 -2
  186. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/ln.js +1 -2
  187. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/log.js +1 -2
  188. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/log10.js +1 -2
  189. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/round.js +1 -2
  190. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/sqrt.js +1 -2
  191. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/subtract.js +5 -2
  192. package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/trunc.js +1 -2
  193. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/arrayElemAt.js +3 -4
  194. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/arrayToObject.js +3 -4
  195. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/concatArrays.js +12 -6
  196. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/filter.js +2 -1
  197. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/first.js +10 -13
  198. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/firstN.js +2 -4
  199. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/in.js +1 -1
  200. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/indexOfArray.js +5 -10
  201. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/isArray.js +2 -3
  202. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/last.js +10 -13
  203. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/lastN.js +2 -4
  204. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/map.js +2 -1
  205. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/maxN.js +2 -4
  206. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/minN.js +2 -4
  207. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/reduce.js +1 -2
  208. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/reverseArray.js +1 -2
  209. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/sortArray.js +2 -4
  210. package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/zip.js +4 -10
  211. package/rust-client/node_modules/mingo/dist/esm/operators/expression/bitwise/_internal.js +1 -2
  212. package/rust-client/node_modules/mingo/dist/esm/operators/expression/bitwise/bitNot.js +2 -4
  213. package/rust-client/node_modules/mingo/dist/esm/operators/expression/boolean/not.js +4 -6
  214. package/rust-client/node_modules/mingo/dist/esm/operators/expression/comparison/cmp.js +6 -5
  215. package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/cond.js +2 -2
  216. package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/ifNull.js +1 -1
  217. package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/switch.js +1 -2
  218. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/_internal.js +140 -61
  219. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateAdd.js +2 -35
  220. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateDiff.js +43 -21
  221. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateFromParts.js +2 -4
  222. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateFromString.js +13 -11
  223. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateToString.js +2 -4
  224. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateTrunc.js +97 -0
  225. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dayOfYear.js +2 -2
  226. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/index.js +1 -0
  227. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/isoWeekYear.js +2 -5
  228. package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/week.js +1 -2
  229. package/rust-client/node_modules/mingo/dist/esm/operators/expression/misc/getField.js +1 -2
  230. package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/mergeObjects.js +10 -3
  231. package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/objectToArray.js +6 -2
  232. package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/setField.js +11 -7
  233. package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setDifference.js +10 -2
  234. package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setEquals.js +18 -4
  235. package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setIntersection.js +3 -2
  236. package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setIsSubset.js +16 -2
  237. package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setUnion.js +5 -6
  238. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/_internal.js +4 -8
  239. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/concat.js +6 -3
  240. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/indexOfBytes.js +2 -4
  241. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/replaceAll.js +1 -2
  242. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/replaceOne.js +1 -2
  243. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/split.js +1 -2
  244. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/strcasecmp.js +1 -2
  245. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/substr.js +4 -14
  246. package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/substrBytes.js +2 -4
  247. package/rust-client/node_modules/mingo/dist/esm/operators/expression/trignometry/atan2.js +2 -4
  248. package/rust-client/node_modules/mingo/dist/esm/operators/expression/trignometry/cosh.js +0 -1
  249. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/_internal.js +17 -11
  250. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/convert.js +3 -5
  251. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toBool.js +2 -4
  252. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toDate.js +4 -7
  253. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toDouble.js +6 -11
  254. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toInt.js +2 -5
  255. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toLong.js +2 -5
  256. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toString.js +12 -11
  257. package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/type.js +12 -15
  258. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/addFields.js +1 -2
  259. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/bucket.js +54 -61
  260. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/bucketAuto.js +679 -66
  261. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/count.js +3 -3
  262. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/densify.js +183 -0
  263. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/graphLookup.js +55 -0
  264. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/group.js +6 -9
  265. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/index.js +2 -0
  266. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/limit.js +1 -3
  267. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/lookup.js +55 -11
  268. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/merge.js +9 -14
  269. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/out.js +2 -2
  270. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/project.js +21 -42
  271. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/redact.js +3 -1
  272. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/replaceWith.js +9 -2
  273. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sample.js +1 -2
  274. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/setWindowFields.js +12 -23
  275. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/skip.js +1 -1
  276. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sort.js +11 -20
  277. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sortByCount.js +5 -3
  278. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unionWith.js +2 -2
  279. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unset.js +1 -2
  280. package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unwind.js +6 -9
  281. package/rust-client/node_modules/mingo/dist/esm/operators/projection/elemMatch.js +3 -4
  282. package/rust-client/node_modules/mingo/dist/esm/operators/projection/slice.js +2 -3
  283. package/rust-client/node_modules/mingo/dist/esm/operators/query/bitwise/_internal.js +4 -4
  284. package/rust-client/node_modules/mingo/dist/esm/operators/update/_internal.js +9 -14
  285. package/rust-client/node_modules/mingo/dist/esm/operators/update/addToSet.js +1 -2
  286. package/rust-client/node_modules/mingo/dist/esm/operators/update/bit.js +1 -2
  287. package/rust-client/node_modules/mingo/dist/esm/operators/update/max.js +1 -2
  288. package/rust-client/node_modules/mingo/dist/esm/operators/update/min.js +1 -2
  289. package/rust-client/node_modules/mingo/dist/esm/operators/update/pop.js +1 -2
  290. package/rust-client/node_modules/mingo/dist/esm/operators/update/pull.js +2 -4
  291. package/rust-client/node_modules/mingo/dist/esm/operators/update/push.js +3 -9
  292. package/rust-client/node_modules/mingo/dist/esm/operators/update/rename.js +1 -2
  293. package/rust-client/node_modules/mingo/dist/esm/operators/update/set.js +1 -2
  294. package/rust-client/node_modules/mingo/dist/esm/operators/update/unset.js +1 -2
  295. package/rust-client/node_modules/mingo/dist/esm/operators/window/_internal.js +2 -3
  296. package/rust-client/node_modules/mingo/dist/esm/operators/window/denseRank.js +8 -10
  297. package/rust-client/node_modules/mingo/dist/esm/operators/window/derivative.js +4 -6
  298. package/rust-client/node_modules/mingo/dist/esm/operators/window/documentNumber.js +1 -3
  299. package/rust-client/node_modules/mingo/dist/esm/operators/window/expMovingAvg.js +4 -6
  300. package/rust-client/node_modules/mingo/dist/esm/operators/window/integral.js +3 -4
  301. package/rust-client/node_modules/mingo/dist/esm/operators/window/linearFill.js +4 -6
  302. package/rust-client/node_modules/mingo/dist/esm/operators/window/locf.js +3 -4
  303. package/rust-client/node_modules/mingo/dist/esm/operators/window/rank.js +8 -10
  304. package/rust-client/node_modules/mingo/dist/esm/operators/window/shift.js +2 -2
  305. package/rust-client/node_modules/mingo/dist/esm/query.js +22 -32
  306. package/rust-client/node_modules/mingo/dist/esm/types.js +14 -0
  307. package/rust-client/node_modules/mingo/dist/esm/updater.js +5 -5
  308. package/rust-client/node_modules/mingo/dist/esm/util.js +263 -377
  309. package/rust-client/node_modules/mingo/dist/types/aggregator.d.ts +7 -9
  310. package/rust-client/node_modules/mingo/dist/types/core.d.ts +41 -52
  311. package/rust-client/node_modules/mingo/dist/types/cursor.d.ts +6 -12
  312. package/rust-client/node_modules/mingo/dist/types/index.d.ts +8 -4
  313. package/rust-client/node_modules/mingo/dist/types/init/basic.d.ts +1 -6
  314. package/rust-client/node_modules/mingo/dist/types/lazy.d.ts +19 -15
  315. package/rust-client/node_modules/mingo/dist/types/operators/_predicates.d.ts +20 -20
  316. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/accumulator.d.ts +1 -1
  317. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/addToSet.d.ts +1 -1
  318. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/avg.d.ts +1 -1
  319. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/bottom.d.ts +2 -2
  320. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/bottomN.d.ts +4 -4
  321. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/count.d.ts +1 -1
  322. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/covariancePop.d.ts +1 -1
  323. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/covarianceSamp.d.ts +1 -1
  324. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/first.d.ts +2 -2
  325. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/firstN.d.ts +1 -1
  326. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/last.d.ts +4 -4
  327. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/lastN.d.ts +1 -1
  328. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/max.d.ts +4 -5
  329. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/maxN.d.ts +1 -1
  330. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/mergeObjects.d.ts +1 -1
  331. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/min.d.ts +4 -5
  332. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/minN.d.ts +1 -1
  333. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/percentile.d.ts +1 -1
  334. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/push.d.ts +4 -4
  335. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/stdDevPop.d.ts +1 -1
  336. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/stdDevSamp.d.ts +1 -1
  337. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/sum.d.ts +5 -3
  338. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/top.d.ts +2 -2
  339. package/rust-client/node_modules/mingo/dist/types/operators/accumulator/topN.d.ts +4 -4
  340. package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/add.d.ts +1 -1
  341. package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/multiply.d.ts +1 -1
  342. package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/pow.d.ts +1 -1
  343. package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/subtract.d.ts +1 -0
  344. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/arrayElemAt.d.ts +1 -1
  345. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/concatArrays.d.ts +3 -3
  346. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/filter.d.ts +1 -1
  347. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/first.d.ts +0 -4
  348. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/firstN.d.ts +1 -1
  349. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/in.d.ts +2 -2
  350. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/indexOfArray.d.ts +1 -1
  351. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/isArray.d.ts +1 -1
  352. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/last.d.ts +0 -4
  353. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/lastN.d.ts +1 -1
  354. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/map.d.ts +1 -1
  355. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/maxN.d.ts +1 -1
  356. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/minN.d.ts +1 -1
  357. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/range.d.ts +1 -1
  358. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/reduce.d.ts +2 -2
  359. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/reverseArray.d.ts +1 -1
  360. package/rust-client/node_modules/mingo/dist/types/operators/expression/array/slice.d.ts +1 -1
  361. package/rust-client/node_modules/mingo/dist/types/operators/expression/date/_internal.d.ts +31 -9
  362. package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateFromString.d.ts +2 -2
  363. package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateToParts.d.ts +2 -2
  364. package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateTrunc.d.ts +12 -0
  365. package/rust-client/node_modules/mingo/dist/types/operators/expression/date/index.d.ts +1 -0
  366. package/rust-client/node_modules/mingo/dist/types/operators/expression/misc/rand.d.ts +2 -2
  367. package/rust-client/node_modules/mingo/dist/types/operators/expression/object/mergeObjects.d.ts +2 -2
  368. package/rust-client/node_modules/mingo/dist/types/operators/expression/percentile.d.ts +1 -1
  369. package/rust-client/node_modules/mingo/dist/types/operators/expression/set/setIsSubset.d.ts +3 -1
  370. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/_internal.d.ts +4 -4
  371. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/indexOfBytes.d.ts +1 -1
  372. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/replaceAll.d.ts +1 -1
  373. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/replaceOne.d.ts +1 -1
  374. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/split.d.ts +1 -1
  375. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/strLenBytes.d.ts +1 -1
  376. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/strLenCP.d.ts +1 -1
  377. package/rust-client/node_modules/mingo/dist/types/operators/expression/string/substrBytes.d.ts +2 -0
  378. package/rust-client/node_modules/mingo/dist/types/operators/expression/type/_internal.d.ts +6 -2
  379. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/_internal.d.ts +4 -4
  380. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/addFields.d.ts +8 -5
  381. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/bucket.d.ts +8 -5
  382. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/bucketAuto.d.ts +8 -7
  383. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/count.d.ts +7 -5
  384. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/densify.d.ts +12 -0
  385. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/facet.d.ts +7 -1
  386. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/fill.d.ts +6 -3
  387. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/graphLookup.d.ts +13 -0
  388. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/group.d.ts +4 -2
  389. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/index.d.ts +2 -0
  390. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/limit.d.ts +3 -1
  391. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/lookup.d.ts +4 -2
  392. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/match.d.ts +4 -3
  393. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/merge.d.ts +3 -5
  394. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/out.d.ts +5 -3
  395. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/project.d.ts +4 -3
  396. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/redact.d.ts +1 -1
  397. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/replaceRoot.d.ts +5 -5
  398. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/replaceWith.d.ts +8 -1
  399. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sample.d.ts +7 -5
  400. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/setWindowFields.d.ts +7 -5
  401. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/skip.d.ts +6 -4
  402. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sort.d.ts +5 -3
  403. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sortByCount.d.ts +5 -5
  404. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unionWith.d.ts +3 -1
  405. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unset.d.ts +2 -0
  406. package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unwind.d.ts +5 -2
  407. package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/expr.d.ts +2 -2
  408. package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/jsonSchema.d.ts +2 -2
  409. package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/where.d.ts +2 -2
  410. package/rust-client/node_modules/mingo/dist/types/operators/update/_internal.d.ts +5 -5
  411. package/rust-client/node_modules/mingo/dist/types/operators/update/addToSet.d.ts +2 -2
  412. package/rust-client/node_modules/mingo/dist/types/operators/update/bit.d.ts +2 -2
  413. package/rust-client/node_modules/mingo/dist/types/operators/update/currentDate.d.ts +2 -2
  414. package/rust-client/node_modules/mingo/dist/types/operators/update/inc.d.ts +2 -2
  415. package/rust-client/node_modules/mingo/dist/types/operators/update/max.d.ts +2 -2
  416. package/rust-client/node_modules/mingo/dist/types/operators/update/min.d.ts +2 -2
  417. package/rust-client/node_modules/mingo/dist/types/operators/update/mul.d.ts +2 -2
  418. package/rust-client/node_modules/mingo/dist/types/operators/update/pop.d.ts +2 -2
  419. package/rust-client/node_modules/mingo/dist/types/operators/update/pull.d.ts +2 -2
  420. package/rust-client/node_modules/mingo/dist/types/operators/update/pullAll.d.ts +2 -2
  421. package/rust-client/node_modules/mingo/dist/types/operators/update/push.d.ts +2 -2
  422. package/rust-client/node_modules/mingo/dist/types/operators/update/rename.d.ts +2 -2
  423. package/rust-client/node_modules/mingo/dist/types/operators/update/set.d.ts +2 -2
  424. package/rust-client/node_modules/mingo/dist/types/operators/update/unset.d.ts +2 -2
  425. package/rust-client/node_modules/mingo/dist/types/operators/window/_internal.d.ts +5 -5
  426. package/rust-client/node_modules/mingo/dist/types/operators/window/denseRank.d.ts +2 -3
  427. package/rust-client/node_modules/mingo/dist/types/operators/window/derivative.d.ts +2 -3
  428. package/rust-client/node_modules/mingo/dist/types/operators/window/documentNumber.d.ts +2 -2
  429. package/rust-client/node_modules/mingo/dist/types/operators/window/expMovingAvg.d.ts +2 -2
  430. package/rust-client/node_modules/mingo/dist/types/operators/window/integral.d.ts +2 -2
  431. package/rust-client/node_modules/mingo/dist/types/operators/window/linearFill.d.ts +2 -2
  432. package/rust-client/node_modules/mingo/dist/types/operators/window/locf.d.ts +2 -2
  433. package/rust-client/node_modules/mingo/dist/types/operators/window/rank.d.ts +2 -2
  434. package/rust-client/node_modules/mingo/dist/types/operators/window/shift.d.ts +2 -2
  435. package/rust-client/node_modules/mingo/dist/types/query.d.ts +5 -7
  436. package/rust-client/node_modules/mingo/dist/types/types.d.ts +18 -15
  437. package/rust-client/node_modules/mingo/dist/types/updater.d.ts +9 -10
  438. package/rust-client/node_modules/mingo/dist/types/util.d.ts +102 -90
  439. package/rust-client/node_modules/mingo/package.json +1 -1
@@ -1,238 +1,215 @@
1
1
  class MingoError extends Error {
2
2
  }
3
- const MAX_INT = 2147483647;
4
- const MIN_INT = -2147483648;
5
- const MAX_LONG = Number.MAX_SAFE_INTEGER;
6
- const MIN_LONG = Number.MIN_SAFE_INTEGER;
7
3
  const MISSING = Symbol("missing");
8
4
  const CYCLE_FOUND_ERROR = Object.freeze(
9
5
  new Error("mingo: cycle detected while processing object/array")
10
6
  );
11
- const OBJECT_TAG = "[object Object]";
12
- const OBJECT_TYPE_RE = /^\[object ([a-zA-Z0-9]+)\]$/;
13
7
  const DEFAULT_HASH_FUNCTION = (value) => {
14
8
  const s = stringify(value);
15
9
  let hash = 0;
16
10
  let i = s.length;
17
- while (i)
18
- hash = (hash << 5) - hash ^ s.charCodeAt(--i);
11
+ while (i) hash = (hash << 5) - hash ^ s.charCodeAt(--i);
19
12
  return hash >>> 0;
20
13
  };
21
- const JS_SIMPLE_TYPES = /* @__PURE__ */ new Set([
22
- "null",
23
- "undefined",
24
- "boolean",
25
- "number",
26
- "string",
27
- "date",
28
- "regexp"
29
- ]);
30
- const SORT_ORDER_BY_TYPE = {
31
- null: 0,
32
- undefined: 0,
33
- number: 1,
34
- string: 2,
35
- object: 3,
36
- array: 4,
37
- boolean: 5,
38
- date: 6,
39
- regexp: 7,
40
- function: 8
14
+ const objectProto = Object.prototype;
15
+ const arrayProto = Array.prototype;
16
+ const getPrototypeOf = Object.getPrototypeOf;
17
+ const isPrimitive = (v) => typeof v !== "object" && typeof v !== "function" || v === null;
18
+ const isScalar = (v) => isPrimitive(v) || isDate(v) || isRegExp(v);
19
+ const SORT_ORDER = {
20
+ undefined: 1,
21
+ null: 2,
22
+ number: 3,
23
+ string: 4,
24
+ symbol: 5,
25
+ object: 6,
26
+ array: 7,
27
+ arraybuffer: 8,
28
+ boolean: 9,
29
+ date: 10,
30
+ regexp: 11,
31
+ function: 12
41
32
  };
42
33
  const compare = (a, b) => {
43
- if (a === MISSING)
44
- a = void 0;
45
- if (b === MISSING)
46
- b = void 0;
47
- const [u, v] = [a, b].map(
48
- (n) => SORT_ORDER_BY_TYPE[getType(n).toLowerCase()]
49
- );
50
- if (u !== v)
51
- return u - v;
52
- if (u === 1 || u === 2 || u === 6) {
53
- if (a < b)
54
- return -1;
55
- if (a > b)
56
- return 1;
57
- return 0;
58
- }
59
- if (isEqual(a, b))
60
- return 0;
61
- if (a < b)
62
- return -1;
63
- if (a > b)
64
- return 1;
34
+ if (a === MISSING) a = void 0;
35
+ if (b === MISSING) b = void 0;
36
+ const [u, v] = [a, b].map((n) => SORT_ORDER[typeOf(n)]);
37
+ if (u !== v) return u - v;
38
+ if (isEqual(a, b)) return 0;
39
+ if (a < b) return -1;
40
+ if (a > b) return 1;
65
41
  return 0;
66
42
  };
43
+ class ValueMap extends Map {
44
+ // The hash function
45
+ #hashFn = DEFAULT_HASH_FUNCTION;
46
+ // maps the hashcode to key set
47
+ #keyMap = /* @__PURE__ */ new Map();
48
+ // returns a tuple of [<masterKey>, <hash>]. Expects an object key.
49
+ #unpack = (key) => {
50
+ const hash = this.#hashFn(key);
51
+ return [(this.#keyMap.get(hash) || []).find((k) => isEqual(k, key)), hash];
52
+ };
53
+ constructor() {
54
+ super();
55
+ }
56
+ /**
57
+ * Returns a new {@link ValueMap} object.
58
+ * @param fn An optional custom hash function
59
+ */
60
+ static init(fn) {
61
+ const m = new ValueMap();
62
+ if (fn) m.#hashFn = fn;
63
+ return m;
64
+ }
65
+ clear() {
66
+ super.clear();
67
+ this.#keyMap.clear();
68
+ }
69
+ /**
70
+ * @returns true if an element in the Map existed and has been removed, or false if the element does not exist.
71
+ */
72
+ delete(key) {
73
+ if (isPrimitive(key)) return super.delete(key);
74
+ const [masterKey, hash] = this.#unpack(key);
75
+ if (!super.delete(masterKey)) return false;
76
+ this.#keyMap.set(
77
+ hash,
78
+ this.#keyMap.get(hash).filter((k) => !isEqual(k, masterKey))
79
+ );
80
+ return true;
81
+ }
82
+ /**
83
+ * Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
84
+ * @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
85
+ */
86
+ get(key) {
87
+ if (isPrimitive(key)) return super.get(key);
88
+ const [masterKey, _] = this.#unpack(key);
89
+ return super.get(masterKey);
90
+ }
91
+ /**
92
+ * @returns boolean indicating whether an element with the specified key exists or not.
93
+ */
94
+ has(key) {
95
+ if (isPrimitive(key)) return super.has(key);
96
+ const [masterKey, _] = this.#unpack(key);
97
+ return super.has(masterKey);
98
+ }
99
+ /**
100
+ * Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
101
+ */
102
+ set(key, value) {
103
+ if (isPrimitive(key)) return super.set(key, value);
104
+ const [masterKey, hash] = this.#unpack(key);
105
+ if (super.has(masterKey)) {
106
+ super.set(masterKey, value);
107
+ } else {
108
+ super.set(key, value);
109
+ const keys = this.#keyMap.get(hash) || [];
110
+ keys.push(key);
111
+ this.#keyMap.set(hash, keys);
112
+ }
113
+ return this;
114
+ }
115
+ /**
116
+ * @returns the number of elements in the Map.
117
+ */
118
+ get size() {
119
+ return super.size;
120
+ }
121
+ }
67
122
  function assert(condition, message) {
68
- if (!condition)
69
- throw new MingoError(message);
123
+ if (!condition) throw new MingoError(message);
70
124
  }
71
- const getType = (v) => OBJECT_TYPE_RE.exec(Object.prototype.toString.call(v))[1];
125
+ const typeOf = (v) => {
126
+ const s = objectProto.toString.call(v);
127
+ const t = s.substring(8, s.length - 1).toLowerCase();
128
+ if (t !== "object") return t;
129
+ const ctor = v.constructor;
130
+ return ctor == null || ctor === Object ? t : ctor.name;
131
+ };
72
132
  const isBoolean = (v) => typeof v === "boolean";
73
133
  const isString = (v) => typeof v === "string";
74
134
  const isSymbol = (v) => typeof v === "symbol";
75
135
  const isNumber = (v) => !isNaN(v) && typeof v === "number";
76
- const isBigInt = (v) => !isNaN(v) && typeof v === "bigint";
77
136
  const isNotNaN = (v) => !(isNaN(v) && typeof v === "number");
78
137
  const isArray = Array.isArray;
79
138
  const isObject = (v) => {
80
- if (!v)
81
- return false;
82
- const proto = Object.getPrototypeOf(v);
83
- return (proto === Object.prototype || proto === null) && OBJECT_TAG === Object.prototype.toString.call(v);
139
+ if (!v) return false;
140
+ const p = Object.getPrototypeOf(v);
141
+ return (p === Object.prototype || p === null) && typeOf(v) === "object";
84
142
  };
85
- const isObjectLike = (v) => v === Object(v);
143
+ const isObjectLike = (v) => !isPrimitive(v);
86
144
  const isDate = (v) => v instanceof Date;
87
145
  const isRegExp = (v) => v instanceof RegExp;
88
146
  const isFunction = (v) => typeof v === "function";
89
147
  const isNil = (v) => v === null || v === void 0;
90
- const inArray = (arr, item) => arr.includes(item);
91
- const notInArray = (arr, item) => !inArray(arr, item);
92
148
  const truthy = (arg, strict = true) => !!arg || strict && arg === "";
93
- const isEmpty = (x) => isNil(x) || isString(x) && !x || x instanceof Array && x.length === 0 || isObject(x) && Object.keys(x).length === 0;
94
- const isMissing = (v) => v === MISSING;
95
- const ensureArray = (x) => x instanceof Array ? x : [x];
96
- const has = (obj, prop) => !!obj && Object.prototype.hasOwnProperty.call(obj, prop);
149
+ const isEmpty = (x) => isNil(x) || isString(x) && !x || isArray(x) && x.length === 0 || isObject(x) && Object.keys(x).length === 0;
150
+ const ensureArray = (x) => isArray(x) ? x : [x];
151
+ const has = (obj, prop) => !!obj && objectProto.hasOwnProperty.call(obj, prop);
97
152
  const isTypedArray = (v) => typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView(v);
98
- const INSTANCE_CLONE = [isDate, isRegExp, isTypedArray];
99
- const cloneInternal = (val, refs) => {
100
- if (isNil(val))
101
- return val;
102
- if (refs.has(val))
103
- throw CYCLE_FOUND_ERROR;
104
- const ctor = val.constructor;
105
- if (INSTANCE_CLONE.some((f) => f(val)))
106
- return new ctor(val);
153
+ const cloneDeep = (v, refs) => {
154
+ if (isNil(v) || isBoolean(v) || isNumber(v) || isString(v)) return v;
155
+ if (isDate(v)) return new Date(v);
156
+ if (isRegExp(v)) return new RegExp(v);
157
+ if (isTypedArray(v)) {
158
+ const ctor = v.constructor;
159
+ return new ctor(v);
160
+ }
161
+ if (!(refs instanceof Set)) refs = /* @__PURE__ */ new Set();
162
+ if (refs.has(v)) throw CYCLE_FOUND_ERROR;
163
+ refs.add(v);
107
164
  try {
108
- refs.add(val);
109
- if (isArray(val))
110
- return val.map((v) => cloneInternal(v, refs));
111
- if (isObject(val)) {
112
- const res = {};
113
- for (const k in val)
114
- res[k] = cloneInternal(val[k], refs);
115
- return res;
165
+ if (isArray(v)) {
166
+ const arr = new Array(v.length);
167
+ for (let i = 0; i < v.length; i++) arr[i] = cloneDeep(v[i], refs);
168
+ return arr;
169
+ }
170
+ if (isObject(v)) {
171
+ const obj = {};
172
+ for (const k of Object.keys(v)) obj[k] = cloneDeep(v[k], refs);
173
+ return obj;
116
174
  }
117
175
  } finally {
118
- refs.delete(val);
176
+ refs.delete(v);
119
177
  }
120
- return val;
178
+ return v;
121
179
  };
122
- const cloneDeep = (obj) => cloneInternal(obj, /* @__PURE__ */ new Set());
123
- const mergeable = (left, right) => isObject(left) && isObject(right) || isArray(left) && isArray(right);
124
- function merge(target, obj, options) {
125
- options = options || { flatten: false };
126
- if (isMissing(target) || isNil(target))
127
- return obj;
128
- if (isMissing(obj) || isNil(obj))
129
- return target;
130
- if (!mergeable(target, obj)) {
131
- if (options.skipValidation)
132
- return obj || target;
133
- throw Error("mismatched types. must both be array or object");
180
+ const isMissing = (v) => v === MISSING;
181
+ function merge(target, input) {
182
+ if (isMissing(target) || isNil(target)) return input;
183
+ if (isMissing(input) || isNil(input)) return target;
184
+ if (isPrimitive(target) || isPrimitive(input)) return input;
185
+ if (isArray(target) && isArray(input)) {
186
+ assert(
187
+ target.length === input.length,
188
+ "arrays must be of equal length to merge."
189
+ );
134
190
  }
135
- options.skipValidation = true;
136
- if (isArray(target)) {
137
- const result = target;
138
- const input = obj;
139
- if (options.flatten) {
140
- let i = 0;
141
- let j = 0;
142
- while (i < result.length && j < input.length) {
143
- result[i] = merge(result[i++], input[j++], options);
144
- }
145
- while (j < input.length) {
146
- result.push(obj[j++]);
147
- }
148
- } else {
149
- into(result, input);
150
- }
151
- } else {
152
- for (const k in obj) {
153
- target[k] = merge(
154
- target[k],
155
- obj[k],
156
- options
157
- );
158
- }
191
+ for (const k in input) {
192
+ target[k] = merge(target[k], input[k]);
159
193
  }
160
194
  return target;
161
195
  }
162
- function buildHashIndex(arr, hashFunction = DEFAULT_HASH_FUNCTION) {
163
- const map = /* @__PURE__ */ new Map();
164
- arr.forEach((o, i) => {
165
- const h = hashCode(o, hashFunction);
166
- if (map.has(h)) {
167
- if (!map.get(h).some((j) => isEqual(arr[j], o))) {
168
- map.get(h).push(i);
169
- }
170
- } else {
171
- map.set(h, [i]);
172
- }
173
- });
174
- return map;
175
- }
176
196
  function intersection(input, hashFunction = DEFAULT_HASH_FUNCTION) {
177
- if (input.some((arr) => arr.length == 0))
178
- return [];
179
- if (input.length === 1)
180
- return Array.from(input);
181
- const sortedIndex = sortBy(
182
- input.map((a, i) => [i, a.length]),
183
- (a) => a[1]
184
- );
185
- const smallest = input[sortedIndex[0][0]];
186
- const map = buildHashIndex(smallest, hashFunction);
187
- const rmap = /* @__PURE__ */ new Map();
188
- const results = new Array();
189
- map.forEach((v, k) => {
190
- const lhs = v.map((j) => smallest[j]);
191
- const res = lhs.map((_) => 0);
192
- const stable = lhs.map((_) => [sortedIndex[0][0], 0]);
193
- let found = false;
194
- for (let i = 1; i < input.length; i++) {
195
- const [currIndex, _] = sortedIndex[i];
196
- const arr = input[currIndex];
197
- if (!rmap.has(i))
198
- rmap.set(i, buildHashIndex(arr));
199
- if (rmap.get(i).has(k)) {
200
- const rhs = rmap.get(i).get(k).map((j) => arr[j]);
201
- found = lhs.map(
202
- (s, n) => rhs.some((t, m) => {
203
- const p = res[n];
204
- if (isEqual(s, t)) {
205
- res[n]++;
206
- if (currIndex < stable[n][0]) {
207
- stable[n] = [currIndex, rmap.get(i).get(k)[m]];
208
- }
209
- }
210
- return p < res[n];
211
- })
212
- ).some(Boolean);
213
- }
214
- if (!found)
215
- return;
216
- }
217
- if (found) {
218
- into(
219
- results,
220
- res.map((n, i) => {
221
- return n === input.length - 1 ? [lhs[i], stable[i]] : MISSING;
222
- }).filter((n) => n !== MISSING)
223
- );
224
- }
225
- });
226
- return results.sort((a, b) => {
227
- const [_i, [u, m]] = a;
228
- const [_j, [v, n]] = b;
229
- const r = compare(u, v);
230
- if (r !== 0)
231
- return r;
232
- return compare(m, n);
233
- }).map((v) => v[0]);
197
+ const vmaps = [ValueMap.init(hashFunction), ValueMap.init(hashFunction)];
198
+ if (input.length === 0) return [];
199
+ if (input.some((arr) => arr.length === 0)) return [];
200
+ if (input.length === 1) return [...input];
201
+ input[input.length - 1].forEach((v) => vmaps[0].set(v, true));
202
+ for (let i = input.length - 2; i > -1; i--) {
203
+ input[i].forEach((v) => {
204
+ if (vmaps[0].has(v)) vmaps[1].set(v, true);
205
+ });
206
+ if (vmaps[1].size === 0) return [];
207
+ vmaps.reverse();
208
+ vmaps[1].clear();
209
+ }
210
+ return Array.from(vmaps[0].keys());
234
211
  }
235
- function flatten(xs, depth = 0) {
212
+ function flatten(xs, depth = 1) {
236
213
  const arr = new Array();
237
214
  function flatten2(ys, n) {
238
215
  for (let i = 0, len = ys.length; i < len; i++) {
@@ -246,24 +223,8 @@ function flatten(xs, depth = 0) {
246
223
  flatten2(xs, depth);
247
224
  return arr;
248
225
  }
249
- const getMembersOf = (value) => {
250
- let [proto, names] = [
251
- Object.getPrototypeOf(value),
252
- Object.getOwnPropertyNames(value)
253
- ];
254
- let activeProto = proto;
255
- while (!names.length && proto !== Object.prototype && proto !== Array.prototype) {
256
- activeProto = proto;
257
- names = Object.getOwnPropertyNames(proto);
258
- proto = Object.getPrototypeOf(proto);
259
- }
260
- const o = {};
261
- names.forEach((k) => o[k] = value[k]);
262
- return [o, activeProto];
263
- };
264
226
  function isEqual(a, b) {
265
- if (a === b || Object.is(a, b))
266
- return true;
227
+ if (a === b || Object.is(a, b)) return true;
267
228
  const ctor = !!a && a.constructor || a;
268
229
  if (a === null || b === null || a === void 0 || b === void 0 || ctor !== b.constructor || ctor === Function) {
269
230
  return false;
@@ -271,96 +232,56 @@ function isEqual(a, b) {
271
232
  if (ctor === Array || ctor === Object) {
272
233
  const aKeys = Object.keys(a);
273
234
  const bKeys = Object.keys(b);
274
- if (aKeys.length !== bKeys.length)
275
- return false;
276
- if ((/* @__PURE__ */ new Set([...aKeys, ...bKeys])).size != aKeys.length)
277
- return false;
278
- for (const k of aKeys)
279
- if (!isEqual(a[k], b[k]))
280
- return false;
235
+ if (aKeys.length !== bKeys.length) return false;
236
+ if ((/* @__PURE__ */ new Set([...aKeys, ...bKeys])).size != aKeys.length) return false;
237
+ for (const k of aKeys) if (!isEqual(a[k], b[k])) return false;
281
238
  return true;
282
239
  }
283
- const proto = Object.getPrototypeOf(a);
284
- const cmp = isTypedArray(a) || proto !== Object.prototype && proto !== Array.prototype && Object.prototype.hasOwnProperty.call(proto, "toString");
240
+ const proto = getPrototypeOf(a);
241
+ const cmp = isTypedArray(a) || proto !== objectProto && proto !== arrayProto && has(proto, "toString");
285
242
  return cmp && a.toString() === b.toString();
286
243
  }
287
244
  function unique(input, hashFunction = DEFAULT_HASH_FUNCTION) {
288
- const result = input.map((_) => MISSING);
289
- buildHashIndex(input, hashFunction).forEach((v, _) => {
290
- v.forEach((i) => result[i] = input[i]);
291
- });
292
- return result.filter((v) => v !== MISSING);
245
+ const m = ValueMap.init(hashFunction);
246
+ input.forEach((v) => m.set(v, true));
247
+ return Array.from(m.keys());
293
248
  }
294
- const toString = (v, cycle) => {
295
- if (v === null)
296
- return "null";
297
- if (v === void 0)
298
- return "undefined";
299
- const ctor = v.constructor;
300
- switch (ctor) {
301
- case RegExp:
302
- case Number:
303
- case Boolean:
304
- case Function:
305
- case Symbol:
306
- return v.toString();
307
- case String:
308
- return JSON.stringify(v);
309
- case Date:
310
- return v.toISOString();
311
- }
249
+ const stringify = (v, refs) => {
250
+ if (v === null) return "null";
251
+ if (v === void 0) return "undefined";
252
+ if (isString(v) || isNumber(v) || isBoolean(v)) return JSON.stringify(v);
253
+ if (isDate(v)) return v.toISOString();
254
+ if (isRegExp(v) || isSymbol(v) || isFunction(v))
255
+ return v.toString();
312
256
  if (isTypedArray(v))
313
- return ctor.name + "[" + v.toString() + "]";
314
- if (cycle.has(v))
315
- throw CYCLE_FOUND_ERROR;
257
+ return typeOf(v) + "[" + v.toString() + "]";
258
+ if (!(refs instanceof Set)) refs = /* @__PURE__ */ new Set();
259
+ if (refs.has(v)) throw CYCLE_FOUND_ERROR;
316
260
  try {
317
- cycle.add(v);
318
- if (isArray(v)) {
319
- return "[" + v.map((s) => toString(s, cycle)).join(",") + "]";
320
- }
321
- if (ctor === Object) {
322
- return "{" + Object.keys(v).sort().map((k) => k + ":" + toString(v[k], cycle)).join(",") + "}";
261
+ refs.add(v);
262
+ if (isArray(v)) return "[" + v.map((s) => stringify(s, refs)).join(",") + "]";
263
+ if (isObject(v)) {
264
+ const keys = Object.keys(v).sort();
265
+ return "{" + keys.map((k) => `${k}:${stringify(v[k], refs)}`).join() + "}";
323
266
  }
324
267
  const proto = Object.getPrototypeOf(v);
325
- if (proto !== Object.prototype && proto !== Array.prototype && Object.prototype.hasOwnProperty.call(proto, "toString")) {
326
- return ctor.name + "(" + JSON.stringify(v.toString()) + ")";
268
+ if (proto !== objectProto && proto !== arrayProto && has(proto, "toString")) {
269
+ return typeOf(v) + "(" + JSON.stringify(v.toString()) + ")";
327
270
  }
328
- const [members, _] = getMembersOf(v);
329
- return ctor.name + toString(members, cycle);
271
+ throw new Error(
272
+ "mingo: cannot stringify custom type without explicit toString() method."
273
+ );
330
274
  } finally {
331
- cycle.delete(v);
275
+ refs.delete(v);
332
276
  }
333
277
  };
334
- const stringify = (value) => toString(value, /* @__PURE__ */ new Set());
335
278
  function hashCode(value, hashFunction) {
279
+ if (isNil(value)) return null;
336
280
  hashFunction = hashFunction || DEFAULT_HASH_FUNCTION;
337
- if (isNil(value))
338
- return null;
339
- return hashFunction(value).toString();
340
- }
341
- function sortBy(collection, keyFn, comparator = compare) {
342
- if (isEmpty(collection))
343
- return collection;
344
- const sorted = new Array();
345
- const result = new Array();
346
- for (let i = 0; i < collection.length; i++) {
347
- const obj = collection[i];
348
- const key = keyFn(obj, i);
349
- if (isNil(key)) {
350
- result.push(obj);
351
- } else {
352
- sorted.push([key, obj]);
353
- }
354
- }
355
- sorted.sort((a, b) => comparator(a[0], b[0]));
356
- return into(
357
- result,
358
- sorted.map((o) => o[1])
359
- );
281
+ return hashFunction(value);
360
282
  }
361
283
  function groupBy(collection, keyFn, hashFunction = DEFAULT_HASH_FUNCTION) {
362
- if (collection.length < 1)
363
- return /* @__PURE__ */ new Map();
284
+ if (collection.length < 1) return /* @__PURE__ */ new Map();
364
285
  const lookup = /* @__PURE__ */ new Map();
365
286
  const result = /* @__PURE__ */ new Map();
366
287
  for (let i = 0; i < collection.length; i++) {
@@ -391,22 +312,19 @@ function groupBy(collection, keyFn, hashFunction = DEFAULT_HASH_FUNCTION) {
391
312
  }
392
313
  const MAX_ARRAY_PUSH = 5e4;
393
314
  function into(target, ...rest) {
394
- if (target instanceof Array) {
395
- return rest.reduce(
396
- (acc, arr) => {
397
- let i = Math.ceil(arr.length / MAX_ARRAY_PUSH);
398
- let begin = 0;
399
- while (i-- > 0) {
400
- Array.prototype.push.apply(
401
- acc,
402
- arr.slice(begin, begin + MAX_ARRAY_PUSH)
403
- );
404
- begin += MAX_ARRAY_PUSH;
405
- }
406
- return acc;
407
- },
408
- target
409
- );
315
+ if (isArray(target)) {
316
+ for (const arr of rest) {
317
+ let i = Math.ceil(arr.length / MAX_ARRAY_PUSH);
318
+ let begin = 0;
319
+ while (i-- > 0) {
320
+ Array.prototype.push.apply(
321
+ target,
322
+ arr.slice(begin, begin + MAX_ARRAY_PUSH)
323
+ );
324
+ begin += MAX_ARRAY_PUSH;
325
+ }
326
+ }
327
+ return target;
410
328
  } else {
411
329
  return rest.filter(isObjectLike).reduce((acc, item) => {
412
330
  Object.assign(acc, item);
@@ -414,27 +332,12 @@ function into(target, ...rest) {
414
332
  }, target);
415
333
  }
416
334
  }
417
- function memoize(fn, hashFunction = DEFAULT_HASH_FUNCTION) {
418
- return /* @__PURE__ */ ((memo) => {
419
- return (...args) => {
420
- const key = hashCode(args, hashFunction) || "";
421
- if (!has(memo, key)) {
422
- memo[key] = fn.apply(this, args);
423
- }
424
- return memo[key];
425
- };
426
- })({
427
- /* storage */
428
- });
429
- }
430
335
  function getValue(obj, key) {
431
- return isObjectLike(obj) ? obj[key] : void 0;
336
+ return isArray(obj) || isObject(obj) ? obj[key] : void 0;
432
337
  }
433
338
  function unwrap(arr, depth) {
434
- if (depth < 1)
435
- return arr;
436
- while (depth-- && arr.length === 1)
437
- arr = arr[0];
339
+ if (depth < 1) return arr;
340
+ while (depth-- && arr.length === 1) arr = arr[0];
438
341
  return arr;
439
342
  }
440
343
  function resolve(obj, selector, options) {
@@ -444,72 +347,68 @@ function resolve(obj, selector, options) {
444
347
  for (let i = 0; i < path.length; i++) {
445
348
  const field = path[i];
446
349
  const isText = /^\d+$/.exec(field) === null;
447
- if (isText && value instanceof Array) {
448
- if (i === 0 && depth > 0)
449
- break;
350
+ if (isText && isArray(value)) {
351
+ if (i === 0 && depth > 0) break;
450
352
  depth += 1;
451
353
  const subpath = path.slice(i);
452
354
  value = value.reduce((acc, item) => {
453
355
  const v = resolve2(item, subpath);
454
- if (v !== void 0)
455
- acc.push(v);
356
+ if (v !== void 0) acc.push(v);
456
357
  return acc;
457
358
  }, []);
458
359
  break;
459
360
  } else {
460
361
  value = getValue(value, field);
461
362
  }
462
- if (value === void 0)
463
- break;
363
+ if (value === void 0) break;
464
364
  }
465
365
  return value;
466
366
  }
467
- const result = JS_SIMPLE_TYPES.has(getType(obj).toLowerCase()) ? obj : resolve2(obj, selector.split("."));
468
- return result instanceof Array && options?.unwrapArray ? unwrap(result, depth) : result;
367
+ const res = isScalar(obj) ? obj : resolve2(obj, selector.split("."));
368
+ return isArray(res) && options?.unwrapArray ? unwrap(res, depth) : res;
469
369
  }
470
370
  function resolveGraph(obj, selector, options) {
471
- const names = selector.split(".");
472
- const key = names[0];
473
- const next = names.slice(1).join(".");
474
- const isIndex = /^\d+$/.exec(key) !== null;
475
- const hasNext = names.length > 1;
476
- let result;
477
- let value;
478
- if (obj instanceof Array) {
371
+ const sep = selector.indexOf(".");
372
+ const key = sep == -1 ? selector : selector.substring(0, sep);
373
+ const next = selector.substring(sep + 1);
374
+ const hasNext = sep != -1;
375
+ if (isArray(obj)) {
376
+ const isIndex = /^\d+$/.test(key);
377
+ const arr = isIndex && options?.preserveIndex ? [...obj] : [];
479
378
  if (isIndex) {
480
- result = getValue(obj, Number(key));
379
+ const index = parseInt(key);
380
+ let value2 = getValue(obj, index);
481
381
  if (hasNext) {
482
- result = resolveGraph(result, next, options);
382
+ value2 = resolveGraph(value2, next, options);
383
+ }
384
+ if (options?.preserveIndex) {
385
+ arr[index] = value2;
386
+ } else {
387
+ arr.push(value2);
483
388
  }
484
- result = [result];
485
389
  } else {
486
- result = [];
487
390
  for (const item of obj) {
488
- value = resolveGraph(item, selector, options);
391
+ const value2 = resolveGraph(item, selector, options);
489
392
  if (options?.preserveMissing) {
490
- if (value === void 0) {
491
- value = MISSING;
492
- }
493
- result.push(value);
494
- } else if (value !== void 0) {
495
- result.push(value);
393
+ arr.push(value2 == void 0 ? MISSING : value2);
394
+ } else if (value2 != void 0 || options?.preserveIndex) {
395
+ arr.push(value2);
496
396
  }
497
397
  }
498
398
  }
499
- } else {
500
- value = getValue(obj, key);
501
- if (hasNext) {
502
- value = resolveGraph(value, next, options);
503
- }
504
- if (value === void 0)
505
- return void 0;
506
- result = options?.preserveKeys ? { ...obj } : {};
507
- result[key] = value;
399
+ return arr;
508
400
  }
509
- return result;
401
+ const res = options?.preserveKeys ? { ...obj } : {};
402
+ let value = getValue(obj, key);
403
+ if (hasNext) {
404
+ value = resolveGraph(value, next, options);
405
+ }
406
+ if (value === void 0) return void 0;
407
+ res[key] = value;
408
+ return res;
510
409
  }
511
410
  function filterMissing(obj) {
512
- if (obj instanceof Array) {
411
+ if (isArray(obj)) {
513
412
  for (let i = obj.length - 1; i >= 0; i--) {
514
413
  if (obj[i] === MISSING) {
515
414
  obj.splice(i, 1);
@@ -539,10 +438,9 @@ function walk(obj, selector, fn, options) {
539
438
  obj[key] = {};
540
439
  }
541
440
  const item = obj[key];
542
- if (!item)
543
- return;
441
+ if (!item) return;
544
442
  const isNextArrayIndex = !!(names.length > 1 && NUMBER_RE.test(names[1]));
545
- if (item instanceof Array && options?.descendArray && !isNextArrayIndex) {
443
+ if (isArray(item) && options?.descendArray && !isNextArrayIndex) {
546
444
  item.forEach((e) => walk(e, next, fn, options));
547
445
  } else {
548
446
  walk(item, next, fn, options);
@@ -564,7 +462,7 @@ function removeValue(obj, selector, options) {
564
462
  obj,
565
463
  selector,
566
464
  (item, key) => {
567
- if (item instanceof Array) {
465
+ if (isArray(item)) {
568
466
  if (/^\d+$/.test(key)) {
569
467
  item.splice(parseInt(key), 1);
570
468
  } else if (options && options.descendArray) {
@@ -586,14 +484,11 @@ function isOperator(name) {
586
484
  return OPERATOR_NAME_PATTERN.test(name);
587
485
  }
588
486
  function normalize(expr) {
589
- if (JS_SIMPLE_TYPES.has(getType(expr).toLowerCase())) {
487
+ if (isScalar(expr)) {
590
488
  return isRegExp(expr) ? { $regex: expr } : { $eq: expr };
591
489
  }
592
490
  if (isObjectLike(expr)) {
593
- const exprObj = expr;
594
- if (!Object.keys(exprObj).some(isOperator)) {
595
- return { $eq: expr };
596
- }
491
+ if (!Object.keys(expr).some(isOperator)) return { $eq: expr };
597
492
  if (has(expr, "$regex")) {
598
493
  const newExpr = { ...expr };
599
494
  newExpr["$regex"] = new RegExp(
@@ -606,14 +501,14 @@ function normalize(expr) {
606
501
  }
607
502
  return expr;
608
503
  }
609
- function findInsertIndex(sorted, item) {
504
+ function findInsertIndex(sorted, item, comparator = compare) {
610
505
  let lo = 0;
611
506
  let hi = sorted.length - 1;
612
507
  while (lo <= hi) {
613
508
  const mid = Math.round(lo + (hi - lo) / 2);
614
- if (compare(item, sorted[mid]) < 0) {
509
+ if (comparator(item, sorted[mid]) < 0) {
615
510
  hi = mid - 1;
616
- } else if (compare(item, sorted[mid]) > 0) {
511
+ } else if (comparator(item, sorted[mid]) > 0) {
617
512
  lo = mid + 1;
618
513
  } else {
619
514
  return mid;
@@ -622,11 +517,8 @@ function findInsertIndex(sorted, item) {
622
517
  return lo;
623
518
  }
624
519
  export {
625
- MAX_INT,
626
- MAX_LONG,
627
- MIN_INT,
628
- MIN_LONG,
629
520
  MingoError,
521
+ ValueMap,
630
522
  assert,
631
523
  cloneDeep,
632
524
  compare,
@@ -634,21 +526,17 @@ export {
634
526
  filterMissing,
635
527
  findInsertIndex,
636
528
  flatten,
637
- getType,
638
529
  groupBy,
639
530
  has,
640
531
  hashCode,
641
- inArray,
642
532
  intersection,
643
533
  into,
644
534
  isArray,
645
- isBigInt,
646
535
  isBoolean,
647
536
  isDate,
648
537
  isEmpty,
649
538
  isEqual,
650
539
  isFunction,
651
- isMissing,
652
540
  isNil,
653
541
  isNotNaN,
654
542
  isNumber,
@@ -658,17 +546,15 @@ export {
658
546
  isRegExp,
659
547
  isString,
660
548
  isSymbol,
661
- memoize,
662
549
  merge,
663
550
  normalize,
664
- notInArray,
665
551
  removeValue,
666
552
  resolve,
667
553
  resolveGraph,
668
554
  setValue,
669
- sortBy,
670
555
  stringify,
671
556
  truthy,
557
+ typeOf,
672
558
  unique,
673
559
  walk
674
560
  };