@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.
- package/build-ts/src/BaseClient.d.ts +27 -1
- package/build-ts/src/BaseClient.js +9 -1
- package/build-ts/src/BaseClient.js.map +1 -1
- package/build-ts/src/Commands.d.ts +12 -0
- package/build-ts/src/Commands.js.map +1 -1
- package/build-ts/src/GlideClient.d.ts +17 -1
- package/build-ts/src/GlideClient.js +3 -0
- package/build-ts/src/GlideClient.js.map +1 -1
- package/build-ts/src/GlideClusterClient.d.ts +23 -7
- package/build-ts/src/GlideClusterClient.js +8 -3
- package/build-ts/src/GlideClusterClient.js.map +1 -1
- package/build-ts/src/ProtobufMessage.js +46 -1
- package/build-ts/src/ProtobufMessage.js.map +1 -1
- package/node_modules/glide-rs/glide-rs.darwin-arm64.node +0 -0
- package/node_modules/glide-rs/index.d.ts +2 -1
- package/node_modules/glide-rs/index.js +4 -2
- package/npm/glide/index.ts +4 -3
- package/npm/glide/package.json +0 -1
- package/package.json +2 -2
- package/rust-client/node_modules/mingo/README.md +58 -53
- package/rust-client/node_modules/mingo/dist/cjs/aggregator.js +18 -20
- package/rust-client/node_modules/mingo/dist/cjs/core.js +179 -190
- package/rust-client/node_modules/mingo/dist/cjs/cursor.js +34 -34
- package/rust-client/node_modules/mingo/dist/cjs/index.js +11 -3
- package/rust-client/node_modules/mingo/dist/cjs/init/basic.js +4 -22
- package/rust-client/node_modules/mingo/dist/cjs/init/system.js +6 -6
- package/rust-client/node_modules/mingo/dist/cjs/lazy.js +58 -61
- package/rust-client/node_modules/mingo/dist/cjs/operators/_predicates.js +12 -25
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/_internal.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/accumulator.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/first.js +3 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/last.js +4 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/max.js +9 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/mergeObjects.js +5 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/min.js +9 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/push.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/accumulator/sum.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/add.js +9 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/ceil.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/exp.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/floor.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/ln.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/log.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/log10.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/round.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/sqrt.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/subtract.js +5 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/arithmetic/trunc.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/arrayElemAt.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/arrayToObject.js +3 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/concatArrays.js +11 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/filter.js +1 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/first.js +8 -8
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/firstN.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/in.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/indexOfArray.js +5 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/isArray.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/last.js +8 -8
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/lastN.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/map.js +1 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/maxN.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/minN.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/reduce.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/reverseArray.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/sortArray.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/array/zip.js +4 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/bitwise/_internal.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/bitwise/bitNot.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/boolean/not.js +3 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/comparison/cmp.js +6 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/cond.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/ifNull.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/conditional/switch.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/_internal.js +157 -65
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateAdd.js +1 -29
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateDiff.js +32 -20
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateFromParts.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateFromString.js +13 -9
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateToString.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dateTrunc.js +107 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/dayOfYear.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/index.js +2 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/isoWeekYear.js +1 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/date/week.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/misc/getField.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/mergeObjects.js +9 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/objectToArray.js +5 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/object/setField.js +11 -7
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setDifference.js +9 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setEquals.js +17 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setIntersection.js +2 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setIsSubset.js +15 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/set/setUnion.js +4 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/_internal.js +4 -8
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/concat.js +5 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/indexOfBytes.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/replaceAll.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/replaceOne.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/split.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/strcasecmp.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/substr.js +4 -14
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/string/substrBytes.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/trignometry/atan2.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/trignometry/cosh.js +0 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/_internal.js +20 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/convert.js +3 -5
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toBool.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toDate.js +3 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toDouble.js +5 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toInt.js +1 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toLong.js +1 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/toString.js +11 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/expression/type/type.js +11 -14
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/addFields.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/bucket.js +53 -53
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/bucketAuto.js +670 -65
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/count.js +2 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/densify.js +196 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/graphLookup.js +78 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/group.js +6 -9
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/index.js +4 -0
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/limit.js +1 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/lookup.js +47 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/merge.js +7 -13
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/out.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/project.js +19 -38
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/redact.js +3 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/replaceWith.js +9 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sample.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/setWindowFields.js +10 -20
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/skip.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sort.js +10 -19
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/sortByCount.js +5 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unionWith.js +1 -1
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unset.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/pipeline/unwind.js +5 -9
- package/rust-client/node_modules/mingo/dist/cjs/operators/projection/elemMatch.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/projection/slice.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/query/bitwise/_internal.js +4 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/_internal.js +8 -14
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/addToSet.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/bit.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/max.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/min.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/pop.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/pull.js +2 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/push.js +3 -9
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/rename.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/set.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/update/unset.js +1 -2
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/_internal.js +2 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/denseRank.js +8 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/derivative.js +4 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/documentNumber.js +1 -3
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/expMovingAvg.js +4 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/integral.js +3 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/linearFill.js +4 -6
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/locf.js +3 -4
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/rank.js +8 -10
- package/rust-client/node_modules/mingo/dist/cjs/operators/window/shift.js +2 -2
- package/rust-client/node_modules/mingo/dist/cjs/query.js +20 -19
- package/rust-client/node_modules/mingo/dist/cjs/types.js +22 -0
- package/rust-client/node_modules/mingo/dist/cjs/updater.js +6 -5
- package/rust-client/node_modules/mingo/dist/cjs/util.js +265 -388
- package/rust-client/node_modules/mingo/dist/esm/aggregator.js +18 -21
- package/rust-client/node_modules/mingo/dist/esm/core.js +179 -192
- package/rust-client/node_modules/mingo/dist/esm/cursor.js +35 -35
- package/rust-client/node_modules/mingo/dist/esm/index.js +8 -2
- package/rust-client/node_modules/mingo/dist/esm/init/basic.js +5 -12
- package/rust-client/node_modules/mingo/dist/esm/init/system.js +7 -7
- package/rust-client/node_modules/mingo/dist/esm/lazy.js +58 -61
- package/rust-client/node_modules/mingo/dist/esm/operators/_predicates.js +14 -32
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/_internal.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/accumulator.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/first.js +7 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/last.js +8 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/max.js +10 -7
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/mergeObjects.js +5 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/min.js +10 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/push.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/accumulator/sum.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/add.js +9 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/ceil.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/exp.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/floor.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/ln.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/log.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/log10.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/round.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/sqrt.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/subtract.js +5 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/arithmetic/trunc.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/arrayElemAt.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/arrayToObject.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/concatArrays.js +12 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/filter.js +2 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/first.js +10 -13
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/firstN.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/in.js +1 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/indexOfArray.js +5 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/isArray.js +2 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/last.js +10 -13
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/lastN.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/map.js +2 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/maxN.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/minN.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/reduce.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/reverseArray.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/sortArray.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/array/zip.js +4 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/bitwise/_internal.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/bitwise/bitNot.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/boolean/not.js +4 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/comparison/cmp.js +6 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/cond.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/ifNull.js +1 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/conditional/switch.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/_internal.js +140 -61
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateAdd.js +2 -35
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateDiff.js +43 -21
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateFromParts.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateFromString.js +13 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateToString.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dateTrunc.js +97 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/dayOfYear.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/index.js +1 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/isoWeekYear.js +2 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/date/week.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/misc/getField.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/mergeObjects.js +10 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/objectToArray.js +6 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/object/setField.js +11 -7
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setDifference.js +10 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setEquals.js +18 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setIntersection.js +3 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setIsSubset.js +16 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/set/setUnion.js +5 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/_internal.js +4 -8
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/concat.js +6 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/indexOfBytes.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/replaceAll.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/replaceOne.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/split.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/strcasecmp.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/substr.js +4 -14
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/string/substrBytes.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/trignometry/atan2.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/trignometry/cosh.js +0 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/_internal.js +17 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/convert.js +3 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toBool.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toDate.js +4 -7
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toDouble.js +6 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toInt.js +2 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toLong.js +2 -5
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/toString.js +12 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/expression/type/type.js +12 -15
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/addFields.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/bucket.js +54 -61
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/bucketAuto.js +679 -66
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/count.js +3 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/densify.js +183 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/graphLookup.js +55 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/group.js +6 -9
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/index.js +2 -0
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/limit.js +1 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/lookup.js +55 -11
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/merge.js +9 -14
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/out.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/project.js +21 -42
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/redact.js +3 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/replaceWith.js +9 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sample.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/setWindowFields.js +12 -23
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/skip.js +1 -1
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sort.js +11 -20
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/sortByCount.js +5 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unionWith.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unset.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/pipeline/unwind.js +6 -9
- package/rust-client/node_modules/mingo/dist/esm/operators/projection/elemMatch.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/projection/slice.js +2 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/query/bitwise/_internal.js +4 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/update/_internal.js +9 -14
- package/rust-client/node_modules/mingo/dist/esm/operators/update/addToSet.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/bit.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/max.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/min.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/pop.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/pull.js +2 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/update/push.js +3 -9
- package/rust-client/node_modules/mingo/dist/esm/operators/update/rename.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/set.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/update/unset.js +1 -2
- package/rust-client/node_modules/mingo/dist/esm/operators/window/_internal.js +2 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/window/denseRank.js +8 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/window/derivative.js +4 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/window/documentNumber.js +1 -3
- package/rust-client/node_modules/mingo/dist/esm/operators/window/expMovingAvg.js +4 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/window/integral.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/window/linearFill.js +4 -6
- package/rust-client/node_modules/mingo/dist/esm/operators/window/locf.js +3 -4
- package/rust-client/node_modules/mingo/dist/esm/operators/window/rank.js +8 -10
- package/rust-client/node_modules/mingo/dist/esm/operators/window/shift.js +2 -2
- package/rust-client/node_modules/mingo/dist/esm/query.js +22 -32
- package/rust-client/node_modules/mingo/dist/esm/types.js +14 -0
- package/rust-client/node_modules/mingo/dist/esm/updater.js +5 -5
- package/rust-client/node_modules/mingo/dist/esm/util.js +263 -377
- package/rust-client/node_modules/mingo/dist/types/aggregator.d.ts +7 -9
- package/rust-client/node_modules/mingo/dist/types/core.d.ts +41 -52
- package/rust-client/node_modules/mingo/dist/types/cursor.d.ts +6 -12
- package/rust-client/node_modules/mingo/dist/types/index.d.ts +8 -4
- package/rust-client/node_modules/mingo/dist/types/init/basic.d.ts +1 -6
- package/rust-client/node_modules/mingo/dist/types/lazy.d.ts +19 -15
- package/rust-client/node_modules/mingo/dist/types/operators/_predicates.d.ts +20 -20
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/accumulator.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/addToSet.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/avg.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/bottom.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/bottomN.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/count.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/covariancePop.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/covarianceSamp.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/first.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/firstN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/last.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/lastN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/max.d.ts +4 -5
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/maxN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/mergeObjects.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/min.d.ts +4 -5
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/minN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/percentile.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/push.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/stdDevPop.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/stdDevSamp.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/sum.d.ts +5 -3
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/top.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/accumulator/topN.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/add.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/multiply.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/pow.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/arithmetic/subtract.d.ts +1 -0
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/arrayElemAt.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/concatArrays.d.ts +3 -3
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/filter.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/first.d.ts +0 -4
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/firstN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/in.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/indexOfArray.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/isArray.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/last.d.ts +0 -4
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/lastN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/map.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/maxN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/minN.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/range.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/reduce.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/reverseArray.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/array/slice.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/_internal.d.ts +31 -9
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateFromString.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateToParts.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/dateTrunc.d.ts +12 -0
- package/rust-client/node_modules/mingo/dist/types/operators/expression/date/index.d.ts +1 -0
- package/rust-client/node_modules/mingo/dist/types/operators/expression/misc/rand.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/object/mergeObjects.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/expression/percentile.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/set/setIsSubset.d.ts +3 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/_internal.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/indexOfBytes.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/replaceAll.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/replaceOne.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/split.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/strLenBytes.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/strLenCP.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/expression/string/substrBytes.d.ts +2 -0
- package/rust-client/node_modules/mingo/dist/types/operators/expression/type/_internal.d.ts +6 -2
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/_internal.d.ts +4 -4
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/addFields.d.ts +8 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/bucket.d.ts +8 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/bucketAuto.d.ts +8 -7
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/count.d.ts +7 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/densify.d.ts +12 -0
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/facet.d.ts +7 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/fill.d.ts +6 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/graphLookup.d.ts +13 -0
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/group.d.ts +4 -2
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/index.d.ts +2 -0
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/limit.d.ts +3 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/lookup.d.ts +4 -2
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/match.d.ts +4 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/merge.d.ts +3 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/out.d.ts +5 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/project.d.ts +4 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/redact.d.ts +1 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/replaceRoot.d.ts +5 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/replaceWith.d.ts +8 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sample.d.ts +7 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/setWindowFields.d.ts +7 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/skip.d.ts +6 -4
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sort.d.ts +5 -3
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/sortByCount.d.ts +5 -5
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unionWith.d.ts +3 -1
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unset.d.ts +2 -0
- package/rust-client/node_modules/mingo/dist/types/operators/pipeline/unwind.d.ts +5 -2
- package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/expr.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/jsonSchema.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/query/evaluation/where.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/_internal.d.ts +5 -5
- package/rust-client/node_modules/mingo/dist/types/operators/update/addToSet.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/bit.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/currentDate.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/inc.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/max.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/min.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/mul.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/pop.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/pull.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/pullAll.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/push.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/rename.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/set.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/update/unset.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/_internal.d.ts +5 -5
- package/rust-client/node_modules/mingo/dist/types/operators/window/denseRank.d.ts +2 -3
- package/rust-client/node_modules/mingo/dist/types/operators/window/derivative.d.ts +2 -3
- package/rust-client/node_modules/mingo/dist/types/operators/window/documentNumber.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/expMovingAvg.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/integral.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/linearFill.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/locf.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/rank.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/operators/window/shift.d.ts +2 -2
- package/rust-client/node_modules/mingo/dist/types/query.d.ts +5 -7
- package/rust-client/node_modules/mingo/dist/types/types.d.ts +18 -15
- package/rust-client/node_modules/mingo/dist/types/updater.d.ts +9 -10
- package/rust-client/node_modules/mingo/dist/types/util.d.ts +102 -90
- package/rust-client/node_modules/mingo/package.json +1 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getOperator,
|
|
3
|
-
initOptions
|
|
4
|
-
OperatorType
|
|
3
|
+
initOptions
|
|
5
4
|
} from "../../core";
|
|
6
|
-
import {
|
|
5
|
+
import { concat, Lazy } from "../../lazy";
|
|
7
6
|
import { assert, isNumber, isOperator, isString } from "../../util";
|
|
8
7
|
import { $function } from "../expression/custom/function";
|
|
9
8
|
import { $dateAdd } from "../expression/date/dateAdd";
|
|
@@ -35,7 +34,7 @@ const $setWindowFields = (collection, expr, options) => {
|
|
|
35
34
|
const keys = Object.keys(outputExpr);
|
|
36
35
|
const op = keys.find(isOperator);
|
|
37
36
|
assert(
|
|
38
|
-
!!getOperator(
|
|
37
|
+
!!getOperator("window", op, options) || !!getOperator("accumulator", op, options),
|
|
39
38
|
`'${op}' is not a valid window operator`
|
|
40
39
|
);
|
|
41
40
|
assert(
|
|
@@ -69,12 +68,8 @@ const $setWindowFields = (collection, expr, options) => {
|
|
|
69
68
|
const config = {
|
|
70
69
|
operatorName: op,
|
|
71
70
|
func: {
|
|
72
|
-
left: getOperator(
|
|
73
|
-
|
|
74
|
-
op,
|
|
75
|
-
options
|
|
76
|
-
),
|
|
77
|
-
right: getOperator(OperatorType.WINDOW, op, options)
|
|
71
|
+
left: getOperator("accumulator", op, options),
|
|
72
|
+
right: getOperator("window", op, options)
|
|
78
73
|
},
|
|
79
74
|
args: outputExpr[op],
|
|
80
75
|
field,
|
|
@@ -124,17 +119,13 @@ const $setWindowFields = (collection, expr, options) => {
|
|
|
124
119
|
if (!isUnbounded(window)) {
|
|
125
120
|
const [begin, end] = boundary;
|
|
126
121
|
const toBeginIndex = (currentIndex) => {
|
|
127
|
-
if (begin == "current")
|
|
128
|
-
|
|
129
|
-
if (begin == "unbounded")
|
|
130
|
-
return 0;
|
|
122
|
+
if (begin == "current") return currentIndex;
|
|
123
|
+
if (begin == "unbounded") return 0;
|
|
131
124
|
return Math.max(begin + currentIndex, 0);
|
|
132
125
|
};
|
|
133
126
|
const toEndIndex = (currentIndex) => {
|
|
134
|
-
if (end == "current")
|
|
135
|
-
|
|
136
|
-
if (end == "unbounded")
|
|
137
|
-
return items.length;
|
|
127
|
+
if (end == "current") return currentIndex + 1;
|
|
128
|
+
if (end == "unbounded") return items.length;
|
|
138
129
|
return end + currentIndex + 1;
|
|
139
130
|
};
|
|
140
131
|
const getItems = (current, index) => {
|
|
@@ -164,10 +155,8 @@ const $setWindowFields = (collection, expr, options) => {
|
|
|
164
155
|
upper = isNumber(end) ? currentValue + end : Infinity;
|
|
165
156
|
}
|
|
166
157
|
let array = items;
|
|
167
|
-
if (begin == "current")
|
|
168
|
-
|
|
169
|
-
if (end == "current")
|
|
170
|
-
array = items.slice(0, index + 1);
|
|
158
|
+
if (begin == "current") array = items.slice(index);
|
|
159
|
+
if (end == "current") array = items.slice(0, index + 1);
|
|
171
160
|
return array.filter((o) => {
|
|
172
161
|
const n = +o[sortKey];
|
|
173
162
|
return n >= lower && n <= upper;
|
|
@@ -194,7 +183,7 @@ const $setWindowFields = (collection, expr, options) => {
|
|
|
194
183
|
}
|
|
195
184
|
iterators.push(iterator);
|
|
196
185
|
});
|
|
197
|
-
return
|
|
186
|
+
return concat(...iterators);
|
|
198
187
|
});
|
|
199
188
|
};
|
|
200
189
|
export {
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
+
assert,
|
|
2
3
|
compare,
|
|
3
4
|
groupBy,
|
|
4
|
-
into,
|
|
5
5
|
isEmpty,
|
|
6
6
|
isObject,
|
|
7
7
|
isString,
|
|
8
8
|
resolve
|
|
9
9
|
} from "../../util";
|
|
10
10
|
const $sort = (collection, sortKeys, options) => {
|
|
11
|
-
if (isEmpty(sortKeys) || !isObject(sortKeys))
|
|
12
|
-
return collection;
|
|
11
|
+
if (isEmpty(sortKeys) || !isObject(sortKeys)) return collection;
|
|
13
12
|
let cmp = compare;
|
|
14
13
|
const collationSpec = options.collation;
|
|
15
14
|
if (isObject(collationSpec) && isString(collationSpec.locale)) {
|
|
@@ -24,13 +23,10 @@ const $sort = (collection, sortKeys, options) => {
|
|
|
24
23
|
options.hashFunction
|
|
25
24
|
);
|
|
26
25
|
const sortedKeys = Array.from(groups.keys()).sort(cmp);
|
|
27
|
-
if (sortKeys[key] === -1)
|
|
28
|
-
|
|
29
|
-
coll =
|
|
30
|
-
|
|
31
|
-
(acc, key2) => into(acc, groups.get(key2)),
|
|
32
|
-
coll
|
|
33
|
-
);
|
|
26
|
+
if (sortKeys[key] === -1) sortedKeys.reverse();
|
|
27
|
+
let i = 0;
|
|
28
|
+
for (const k of sortedKeys) for (const v of groups.get(k)) coll[i++] = v;
|
|
29
|
+
assert(i == coll.length, "bug: counter must match collection size.");
|
|
34
30
|
}
|
|
35
31
|
return coll;
|
|
36
32
|
});
|
|
@@ -54,20 +50,15 @@ function collationComparator(spec) {
|
|
|
54
50
|
ignorePunctuation: spec.alternate === "shifted"
|
|
55
51
|
};
|
|
56
52
|
if ((spec.caseLevel || false) === true) {
|
|
57
|
-
if (localeOpt.sensitivity === "base")
|
|
58
|
-
|
|
59
|
-
if (localeOpt.sensitivity === "accent")
|
|
60
|
-
localeOpt.sensitivity = "variant";
|
|
53
|
+
if (localeOpt.sensitivity === "base") localeOpt.sensitivity = "case";
|
|
54
|
+
if (localeOpt.sensitivity === "accent") localeOpt.sensitivity = "variant";
|
|
61
55
|
}
|
|
62
56
|
const collator = new Intl.Collator(spec.locale, localeOpt);
|
|
63
57
|
return (a, b) => {
|
|
64
|
-
if (!isString(a) || !isString(b))
|
|
65
|
-
return compare(a, b);
|
|
58
|
+
if (!isString(a) || !isString(b)) return compare(a, b);
|
|
66
59
|
const i = collator.compare(a, b);
|
|
67
|
-
if (i < 0)
|
|
68
|
-
|
|
69
|
-
if (i > 0)
|
|
70
|
-
return 1;
|
|
60
|
+
if (i < 0) return -1;
|
|
61
|
+
if (i > 0) return 1;
|
|
71
62
|
return 0;
|
|
72
63
|
};
|
|
73
64
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { $group } from "./group";
|
|
2
2
|
import { $sort } from "./sort";
|
|
3
3
|
const $sortByCount = (collection, expr, options) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
return $sort(
|
|
5
|
+
$group(collection, { _id: expr, count: { $sum: 1 } }, options),
|
|
6
|
+
{ count: -1 },
|
|
7
|
+
options
|
|
8
|
+
);
|
|
7
9
|
};
|
|
8
10
|
export {
|
|
9
11
|
$sortByCount
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Aggregator } from "../../aggregator";
|
|
2
|
-
import {
|
|
2
|
+
import { concat, Lazy } from "../../lazy";
|
|
3
3
|
import { isString } from "../../util";
|
|
4
4
|
const $unionWith = (collection, expr, options) => {
|
|
5
5
|
const array = isString(expr.coll) ? options.collectionResolver(expr.coll) : expr.coll;
|
|
@@ -7,7 +7,7 @@ const $unionWith = (collection, expr, options) => {
|
|
|
7
7
|
iterators.push(
|
|
8
8
|
expr.pipeline ? new Aggregator(expr.pipeline, options).stream(array) : Lazy(array)
|
|
9
9
|
);
|
|
10
|
-
return
|
|
10
|
+
return concat(...iterators);
|
|
11
11
|
};
|
|
12
12
|
export {
|
|
13
13
|
$unionWith
|
|
@@ -3,8 +3,7 @@ import { $project } from "./project";
|
|
|
3
3
|
const $unset = (collection, expr, options) => {
|
|
4
4
|
expr = ensureArray(expr);
|
|
5
5
|
const doc = {};
|
|
6
|
-
for (const k of expr)
|
|
7
|
-
doc[k] = 0;
|
|
6
|
+
for (const k of expr) doc[k] = 0;
|
|
8
7
|
return $project(collection, doc, options);
|
|
9
8
|
};
|
|
10
9
|
export {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Iterator, Lazy } from "../../lazy";
|
|
2
2
|
import {
|
|
3
|
+
isArray,
|
|
3
4
|
isEmpty,
|
|
4
5
|
isString,
|
|
5
6
|
removeValue,
|
|
@@ -8,15 +9,13 @@ import {
|
|
|
8
9
|
setValue
|
|
9
10
|
} from "../../util";
|
|
10
11
|
const $unwind = (collection, expr, _options) => {
|
|
11
|
-
if (isString(expr))
|
|
12
|
-
expr = { path: expr };
|
|
12
|
+
if (isString(expr)) expr = { path: expr };
|
|
13
13
|
const path = expr.path;
|
|
14
14
|
const field = path.substring(1);
|
|
15
15
|
const includeArrayIndex = expr?.includeArrayIndex || false;
|
|
16
16
|
const preserveNullAndEmptyArrays = expr.preserveNullAndEmptyArrays || false;
|
|
17
17
|
const format = (o, i) => {
|
|
18
|
-
if (includeArrayIndex !== false)
|
|
19
|
-
o[includeArrayIndex] = i;
|
|
18
|
+
if (includeArrayIndex !== false) o[includeArrayIndex] = i;
|
|
20
19
|
return o;
|
|
21
20
|
};
|
|
22
21
|
let value;
|
|
@@ -24,15 +23,13 @@ const $unwind = (collection, expr, _options) => {
|
|
|
24
23
|
for (; ; ) {
|
|
25
24
|
if (value instanceof Iterator) {
|
|
26
25
|
const tmp = value.next();
|
|
27
|
-
if (!tmp.done)
|
|
28
|
-
return tmp;
|
|
26
|
+
if (!tmp.done) return tmp;
|
|
29
27
|
}
|
|
30
28
|
const wrapper = collection.next();
|
|
31
|
-
if (wrapper.done)
|
|
32
|
-
return wrapper;
|
|
29
|
+
if (wrapper.done) return wrapper;
|
|
33
30
|
const obj = wrapper.value;
|
|
34
31
|
value = resolve(obj, field);
|
|
35
|
-
if (value
|
|
32
|
+
if (isArray(value)) {
|
|
36
33
|
if (value.length === 0 && preserveNullAndEmptyArrays === true) {
|
|
37
34
|
value = null;
|
|
38
35
|
removeValue(obj, field);
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Query } from "../../query";
|
|
2
|
-
import { assert, resolve } from "../../util";
|
|
2
|
+
import { assert, isArray, resolve } from "../../util";
|
|
3
3
|
const $elemMatch = (obj, expr, field, options) => {
|
|
4
4
|
const arr = resolve(obj, field);
|
|
5
5
|
const query = new Query(expr, options);
|
|
6
|
-
assert(arr
|
|
6
|
+
assert(isArray(arr), "$elemMatch: argument must resolve to array");
|
|
7
7
|
const result = [];
|
|
8
8
|
for (let i = 0; i < arr.length; i++) {
|
|
9
9
|
if (query.test(arr[i])) {
|
|
10
|
-
if (options.useStrictMode)
|
|
11
|
-
return [arr[i]];
|
|
10
|
+
if (options.useStrictMode) return [arr[i]];
|
|
12
11
|
result.push(arr[i]);
|
|
13
12
|
}
|
|
14
13
|
}
|
|
@@ -3,11 +3,10 @@ import { $slice as __slice } from "../expression/array/slice";
|
|
|
3
3
|
const $slice = (obj, expr, field, options) => {
|
|
4
4
|
const xs = resolve(obj, field);
|
|
5
5
|
const exprAsArray = expr;
|
|
6
|
-
if (!isArray(xs))
|
|
7
|
-
return xs;
|
|
6
|
+
if (!isArray(xs)) return xs;
|
|
8
7
|
return __slice(
|
|
9
8
|
obj,
|
|
10
|
-
expr
|
|
9
|
+
isArray(expr) ? [xs, ...exprAsArray] : [xs, expr],
|
|
11
10
|
options
|
|
12
11
|
);
|
|
13
12
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { isArray } from "../../../util";
|
|
1
2
|
import { createQueryOperator } from "../../_predicates";
|
|
2
3
|
const createBitwiseOperator = (predicate) => {
|
|
3
4
|
return createQueryOperator(
|
|
4
|
-
(value, mask,
|
|
5
|
+
(value, mask, _options) => {
|
|
5
6
|
let b = 0;
|
|
6
|
-
if (mask
|
|
7
|
-
for (const n of mask)
|
|
8
|
-
b = b | 1 << n;
|
|
7
|
+
if (isArray(mask)) {
|
|
8
|
+
for (const n of mask) b = b | 1 << n;
|
|
9
9
|
} else {
|
|
10
10
|
b = mask;
|
|
11
11
|
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
isArray,
|
|
6
6
|
isDate,
|
|
7
7
|
isObject,
|
|
8
|
+
isRegExp,
|
|
8
9
|
resolve,
|
|
9
10
|
walk
|
|
10
11
|
} from "../../util";
|
|
@@ -13,12 +14,10 @@ const clone = (mode, val) => {
|
|
|
13
14
|
case "deep":
|
|
14
15
|
return cloneDeep(val);
|
|
15
16
|
case "copy": {
|
|
16
|
-
if (isDate(val))
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
if (isObject(val))
|
|
21
|
-
return { ...val };
|
|
17
|
+
if (isDate(val)) return new Date(val);
|
|
18
|
+
if (isArray(val)) return [...val];
|
|
19
|
+
if (isObject(val)) return { ...val };
|
|
20
|
+
if (isRegExp(val)) return new RegExp(val);
|
|
22
21
|
return val;
|
|
23
22
|
}
|
|
24
23
|
default:
|
|
@@ -54,11 +53,9 @@ const applyUpdate = (o, n, q, f, opts) => {
|
|
|
54
53
|
return b;
|
|
55
54
|
}
|
|
56
55
|
const t = resolve(o, parent);
|
|
57
|
-
if (!isArray(t))
|
|
58
|
-
return false;
|
|
56
|
+
if (!isArray(t)) return false;
|
|
59
57
|
return t.map((e, i) => {
|
|
60
|
-
if (q[c] && !q[c].test({ [c]: e }))
|
|
61
|
-
return false;
|
|
58
|
+
if (q[c] && !q[c].test({ [c]: e })) return false;
|
|
62
59
|
return next ? applyUpdate(e, next, q, f, opts) : f(t, i);
|
|
63
60
|
}).some(Boolean);
|
|
64
61
|
};
|
|
@@ -67,8 +64,7 @@ function walkExpression(expr, arrayFilter, options, callback) {
|
|
|
67
64
|
for (const [selector, val] of Object.entries(expr)) {
|
|
68
65
|
const [node, vars] = tokenizePath(selector);
|
|
69
66
|
if (!vars.length) {
|
|
70
|
-
if (callback(val, node, {}))
|
|
71
|
-
res.push(node.parent);
|
|
67
|
+
if (callback(val, node, {})) res.push(node.parent);
|
|
72
68
|
} else {
|
|
73
69
|
const conditions = {};
|
|
74
70
|
arrayFilter.forEach((o) => {
|
|
@@ -85,8 +81,7 @@ function walkExpression(expr, arrayFilter, options, callback) {
|
|
|
85
81
|
for (const [k, condition] of Object.entries(conditions)) {
|
|
86
82
|
queries[k] = new Query(condition, options.queryOptions);
|
|
87
83
|
}
|
|
88
|
-
if (callback(val, node, queries))
|
|
89
|
-
res.push(node.parent);
|
|
84
|
+
if (callback(val, node, queries)) res.push(node.parent);
|
|
90
85
|
}
|
|
91
86
|
}
|
|
92
87
|
return res;
|
|
@@ -13,8 +13,7 @@ const $addToSet = (obj, expr, arrayFilters = [], options = {}) => {
|
|
|
13
13
|
(o, k) => {
|
|
14
14
|
const prev = o[k] ||= [];
|
|
15
15
|
const common = intersection([prev, args.$each]);
|
|
16
|
-
if (common.length === args.$each.length)
|
|
17
|
-
return false;
|
|
16
|
+
if (common.length === args.$each.length) return false;
|
|
18
17
|
o[k] = clone(options.cloneMode, unique(prev.concat(args.$each)));
|
|
19
18
|
return true;
|
|
20
19
|
},
|
|
@@ -15,8 +15,7 @@ const $bit = (obj, expr, arrayFilters = [], options = {}) => {
|
|
|
15
15
|
(o, k) => {
|
|
16
16
|
let n = o[k];
|
|
17
17
|
const v = val[op[0]];
|
|
18
|
-
if (n !== void 0 && !(isNumber(n) && isNumber(v)))
|
|
19
|
-
return false;
|
|
18
|
+
if (n !== void 0 && !(isNumber(n) && isNumber(v))) return false;
|
|
20
19
|
n = n || 0;
|
|
21
20
|
switch (op[0]) {
|
|
22
21
|
case "and":
|
|
@@ -7,8 +7,7 @@ const $max = (obj, expr, arrayFilters = [], options = {}) => {
|
|
|
7
7
|
node,
|
|
8
8
|
queries,
|
|
9
9
|
(o, k) => {
|
|
10
|
-
if (o[k] !== void 0 && compare(o[k], val) > -1)
|
|
11
|
-
return false;
|
|
10
|
+
if (o[k] !== void 0 && compare(o[k], val) > -1) return false;
|
|
12
11
|
o[k] = val;
|
|
13
12
|
return true;
|
|
14
13
|
},
|
|
@@ -7,8 +7,7 @@ const $min = (obj, expr, arrayFilters = [], options = {}) => {
|
|
|
7
7
|
node,
|
|
8
8
|
queries,
|
|
9
9
|
(o, k) => {
|
|
10
|
-
if (o[k] !== void 0 && compare(o[k], val) < 1)
|
|
11
|
-
return false;
|
|
10
|
+
if (o[k] !== void 0 && compare(o[k], val) < 1) return false;
|
|
12
11
|
o[k] = val;
|
|
13
12
|
return true;
|
|
14
13
|
},
|
|
@@ -8,8 +8,7 @@ const $pop = (obj, expr, arrayFilters = [], options = {}) => {
|
|
|
8
8
|
isArray(arr),
|
|
9
9
|
`path '${node.selector}' contains an element of non-array type.`
|
|
10
10
|
);
|
|
11
|
-
if (!arr.length)
|
|
12
|
-
return false;
|
|
11
|
+
if (!arr.length) return false;
|
|
13
12
|
if (val === -1) {
|
|
14
13
|
arr.splice(0, 1);
|
|
15
14
|
} else {
|
|
@@ -14,12 +14,10 @@ const $pull = (obj, expr, arrayFilters = [], options = {}) => {
|
|
|
14
14
|
const curr = new Array();
|
|
15
15
|
const found = prev.map((v) => {
|
|
16
16
|
const b = pred(v);
|
|
17
|
-
if (!b)
|
|
18
|
-
curr.push(v);
|
|
17
|
+
if (!b) curr.push(v);
|
|
19
18
|
return b;
|
|
20
19
|
}).some(Boolean);
|
|
21
|
-
if (!found)
|
|
22
|
-
return false;
|
|
20
|
+
if (!found) return false;
|
|
23
21
|
o[k] = curr;
|
|
24
22
|
return true;
|
|
25
23
|
});
|
|
@@ -23,11 +23,7 @@ const $push = (obj, expr, arrayFilters = [], options = {}) => {
|
|
|
23
23
|
const prev = arr.slice(0, args.$slice || arr.length);
|
|
24
24
|
const oldsize = arr.length;
|
|
25
25
|
const pos = isNumber(args.$position) ? args.$position : arr.length;
|
|
26
|
-
arr.splice(
|
|
27
|
-
pos,
|
|
28
|
-
0,
|
|
29
|
-
...clone(options.cloneMode, args.$each)
|
|
30
|
-
);
|
|
26
|
+
arr.splice(pos, 0, ...clone(options.cloneMode, args.$each));
|
|
31
27
|
if (args.$sort) {
|
|
32
28
|
const sortKey = isObject(args.$sort) ? Object.keys(args.$sort || {}).pop() : "";
|
|
33
29
|
const order = !sortKey ? args.$sort : args.$sort[sortKey];
|
|
@@ -35,10 +31,8 @@ const $push = (obj, expr, arrayFilters = [], options = {}) => {
|
|
|
35
31
|
arr.sort((a, b) => order * compare(f(a), f(b)));
|
|
36
32
|
}
|
|
37
33
|
if (isNumber(args.$slice)) {
|
|
38
|
-
if (args.$slice < 0)
|
|
39
|
-
|
|
40
|
-
else
|
|
41
|
-
arr.splice(args.$slice);
|
|
34
|
+
if (args.$slice < 0) arr.splice(0, arr.length + args.$slice);
|
|
35
|
+
else arr.splice(args.$slice);
|
|
42
36
|
}
|
|
43
37
|
return oldsize != arr.length || !isEqual(prev, arr);
|
|
44
38
|
},
|
|
@@ -5,8 +5,7 @@ const $rename = (obj, expr, arrayFilters = [], options = {}) => {
|
|
|
5
5
|
const res = [];
|
|
6
6
|
const changed = walkExpression(expr, arrayFilters, options, (val, node, queries) => {
|
|
7
7
|
return applyUpdate(obj, node, queries, (o, k) => {
|
|
8
|
-
if (!has(o, k))
|
|
9
|
-
return false;
|
|
8
|
+
if (!has(o, k)) return false;
|
|
10
9
|
res.push(...$set(obj, { [val]: o[k] }, arrayFilters, options));
|
|
11
10
|
delete o[k];
|
|
12
11
|
return true;
|
|
@@ -3,8 +3,7 @@ import { applyUpdate, walkExpression } from "./_internal";
|
|
|
3
3
|
const $unset = (obj, expr, arrayFilters = [], options = {}) => {
|
|
4
4
|
return walkExpression(expr, arrayFilters, options, (_, node, queries) => {
|
|
5
5
|
return applyUpdate(obj, node, queries, (o, k) => {
|
|
6
|
-
if (!has(o, k))
|
|
7
|
-
return false;
|
|
6
|
+
if (!has(o, k)) return false;
|
|
8
7
|
if (isArray(o)) {
|
|
9
8
|
o[k] = null;
|
|
10
9
|
} else {
|
|
@@ -25,13 +25,12 @@ function withMemo(collection, expr, cacheFn, fn) {
|
|
|
25
25
|
let failed = false;
|
|
26
26
|
try {
|
|
27
27
|
return fn(data[expr.field]);
|
|
28
|
-
} catch
|
|
28
|
+
} catch {
|
|
29
29
|
failed = true;
|
|
30
30
|
} finally {
|
|
31
31
|
if (failed || expr.documentNumber === collection.length) {
|
|
32
32
|
delete data[expr.field];
|
|
33
|
-
if (Object.keys(data).length === 0)
|
|
34
|
-
memo.delete(collection);
|
|
33
|
+
if (Object.keys(data).length === 0) memo.delete(collection);
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { rank } from "./_internal";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
);
|
|
11
|
-
}
|
|
2
|
+
const $denseRank = (obj, collection, expr, options) => rank(
|
|
3
|
+
obj,
|
|
4
|
+
collection,
|
|
5
|
+
expr,
|
|
6
|
+
options,
|
|
7
|
+
true
|
|
8
|
+
/*dense*/
|
|
9
|
+
);
|
|
12
10
|
export {
|
|
13
11
|
$denseRank
|
|
14
12
|
};
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { isNumber } from "../../util";
|
|
2
2
|
import { $push } from "../accumulator";
|
|
3
3
|
import { MILLIS_PER_UNIT } from "./_internal";
|
|
4
|
-
|
|
5
|
-
if (collection.length < 2)
|
|
6
|
-
return null;
|
|
4
|
+
const $derivative = (_, collection, expr, options) => {
|
|
5
|
+
if (collection.length < 2) return null;
|
|
7
6
|
const { input, unit } = expr.inputExpr;
|
|
8
7
|
const sortKey = "$" + Object.keys(expr.parentExpr.sortBy)[0];
|
|
9
8
|
const values = [collection[0], collection[collection.length - 1]];
|
|
10
9
|
const points = $push(values, [sortKey, input], options).filter(
|
|
11
10
|
([x, y]) => isNumber(+x) && isNumber(+y)
|
|
12
11
|
);
|
|
13
|
-
if (points.length !== 2)
|
|
14
|
-
return null;
|
|
12
|
+
if (points.length !== 2) return null;
|
|
15
13
|
const [[x1, y1], [x2, y2]] = points;
|
|
16
14
|
const deltaX = (x2 - x1) / (MILLIS_PER_UNIT[unit] || 1);
|
|
17
15
|
return (y2 - y1) / deltaX;
|
|
18
|
-
}
|
|
16
|
+
};
|
|
19
17
|
export {
|
|
20
18
|
$derivative
|
|
21
19
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { assert, isNumber } from "../../util";
|
|
2
2
|
import { $push } from "../accumulator";
|
|
3
3
|
import { withMemo } from "./_internal";
|
|
4
|
-
|
|
4
|
+
const $expMovingAvg = (_, collection, expr, options) => {
|
|
5
5
|
const { input, N, alpha } = expr.inputExpr;
|
|
6
6
|
assert(
|
|
7
7
|
!(N && alpha),
|
|
@@ -15,17 +15,15 @@ function $expMovingAvg(_, collection, expr, options) {
|
|
|
15
15
|
return series.length === collection.length ? series : null;
|
|
16
16
|
},
|
|
17
17
|
(series) => {
|
|
18
|
-
if (series === null)
|
|
19
|
-
|
|
20
|
-
if (expr.documentNumber == 1)
|
|
21
|
-
return series[0];
|
|
18
|
+
if (series === null) return null;
|
|
19
|
+
if (expr.documentNumber == 1) return series[0];
|
|
22
20
|
const weight = N != void 0 ? 2 / (N + 1) : alpha;
|
|
23
21
|
const i = expr.documentNumber - 1;
|
|
24
22
|
series[i] = series[i] * weight + series[i - 1] * (1 - weight);
|
|
25
23
|
return series[i];
|
|
26
24
|
}
|
|
27
25
|
);
|
|
28
|
-
}
|
|
26
|
+
};
|
|
29
27
|
export {
|
|
30
28
|
$expMovingAvg
|
|
31
29
|
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { isNumber } from "../../util";
|
|
2
2
|
import { $push } from "../accumulator";
|
|
3
3
|
import { MILLIS_PER_UNIT } from "./_internal";
|
|
4
|
-
|
|
4
|
+
const $integral = (_, collection, expr, options) => {
|
|
5
5
|
const { input, unit } = expr.inputExpr;
|
|
6
6
|
const sortKey = "$" + Object.keys(expr.parentExpr.sortBy)[0];
|
|
7
7
|
const points = $push(collection, [sortKey, input], options).filter(
|
|
8
8
|
([x, y]) => isNumber(+x) && isNumber(+y)
|
|
9
9
|
);
|
|
10
|
-
if (points.length !== collection.length)
|
|
11
|
-
return null;
|
|
10
|
+
if (points.length !== collection.length) return null;
|
|
12
11
|
let result = 0;
|
|
13
12
|
const size = collection.length;
|
|
14
13
|
for (let k = 1; k < size; k++) {
|
|
@@ -18,7 +17,7 @@ function $integral(_, collection, expr, options) {
|
|
|
18
17
|
result += 0.5 * (y1 + y2) * deltaX;
|
|
19
18
|
}
|
|
20
19
|
return result;
|
|
21
|
-
}
|
|
20
|
+
};
|
|
22
21
|
export {
|
|
23
22
|
$integral
|
|
24
23
|
};
|
|
@@ -2,7 +2,7 @@ import { isNumber } from "../../util";
|
|
|
2
2
|
import { $push } from "../accumulator";
|
|
3
3
|
import { withMemo } from "./_internal";
|
|
4
4
|
const interpolate = (x1, y1, x2, y2, x) => y1 + (x - x1) * ((y2 - y1) / (x2 - x1));
|
|
5
|
-
|
|
5
|
+
const $linearFill = (_, collection, expr, options) => {
|
|
6
6
|
return withMemo(
|
|
7
7
|
collection,
|
|
8
8
|
expr,
|
|
@@ -13,8 +13,7 @@ function $linearFill(_, collection, expr, options) {
|
|
|
13
13
|
[sortKey, expr.inputExpr],
|
|
14
14
|
options
|
|
15
15
|
).filter(([x, _2]) => isNumber(+x));
|
|
16
|
-
if (points.length !== collection.length)
|
|
17
|
-
return null;
|
|
16
|
+
if (points.length !== collection.length) return null;
|
|
18
17
|
let lindex = -1;
|
|
19
18
|
let rindex = 0;
|
|
20
19
|
while (rindex < points.length) {
|
|
@@ -25,8 +24,7 @@ function $linearFill(_, collection, expr, options) {
|
|
|
25
24
|
while (rindex + 1 < points.length && !isNumber(points[rindex + 1][1])) {
|
|
26
25
|
rindex++;
|
|
27
26
|
}
|
|
28
|
-
if (rindex + 1 >= points.length)
|
|
29
|
-
break;
|
|
27
|
+
if (rindex + 1 >= points.length) break;
|
|
30
28
|
rindex++;
|
|
31
29
|
while (lindex + 1 < rindex) {
|
|
32
30
|
points[lindex + 1][1] = interpolate(
|
|
@@ -44,7 +42,7 @@ function $linearFill(_, collection, expr, options) {
|
|
|
44
42
|
},
|
|
45
43
|
(values) => values[expr.documentNumber - 1]
|
|
46
44
|
);
|
|
47
|
-
}
|
|
45
|
+
};
|
|
48
46
|
export {
|
|
49
47
|
$linearFill
|
|
50
48
|
};
|