@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,36 +1,39 @@
|
|
|
1
1
|
import { Aggregator } from "./aggregator";
|
|
2
|
-
import {
|
|
2
|
+
import { concat, Lazy } from "./lazy";
|
|
3
3
|
import { isObject } from "./util";
|
|
4
4
|
class Cursor {
|
|
5
|
+
#source;
|
|
6
|
+
#predicate;
|
|
7
|
+
#projection;
|
|
8
|
+
#options;
|
|
9
|
+
#operators = [];
|
|
10
|
+
#result = null;
|
|
11
|
+
#buffer = [];
|
|
5
12
|
constructor(source, predicate, projection, options) {
|
|
6
|
-
this
|
|
7
|
-
this
|
|
8
|
-
this
|
|
9
|
-
this
|
|
10
|
-
this.operators = [];
|
|
11
|
-
this.result = null;
|
|
12
|
-
this.buffer = [];
|
|
13
|
+
this.#source = source;
|
|
14
|
+
this.#predicate = predicate;
|
|
15
|
+
this.#projection = projection;
|
|
16
|
+
this.#options = options;
|
|
13
17
|
}
|
|
14
18
|
/** Returns the iterator from running the query */
|
|
15
19
|
fetch() {
|
|
16
|
-
if (this
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.operators.push({ $project: this.projection });
|
|
20
|
+
if (this.#result) return this.#result;
|
|
21
|
+
if (isObject(this.#projection)) {
|
|
22
|
+
this.#operators.push({ $project: this.#projection });
|
|
20
23
|
}
|
|
21
|
-
this
|
|
22
|
-
if (this
|
|
23
|
-
this
|
|
24
|
-
this
|
|
24
|
+
this.#result = Lazy(this.#source).filter(this.#predicate);
|
|
25
|
+
if (this.#operators.length > 0) {
|
|
26
|
+
this.#result = new Aggregator(this.#operators, this.#options).stream(
|
|
27
|
+
this.#result
|
|
25
28
|
);
|
|
26
29
|
}
|
|
27
|
-
return this
|
|
30
|
+
return this.#result;
|
|
28
31
|
}
|
|
29
32
|
/** Returns an iterator with the buffered data included */
|
|
30
33
|
fetchAll() {
|
|
31
|
-
const buffered = Lazy([...this
|
|
32
|
-
this
|
|
33
|
-
return
|
|
34
|
+
const buffered = Lazy([...this.#buffer]);
|
|
35
|
+
this.#buffer = [];
|
|
36
|
+
return concat(buffered, this.fetch());
|
|
34
37
|
}
|
|
35
38
|
/**
|
|
36
39
|
* Return remaining objects in the cursor as an array. This method exhausts the cursor
|
|
@@ -52,7 +55,7 @@ class Cursor {
|
|
|
52
55
|
* @return {Cursor} Returns the cursor, so you can chain this call.
|
|
53
56
|
*/
|
|
54
57
|
skip(n) {
|
|
55
|
-
this
|
|
58
|
+
this.#operators.push({ $skip: n });
|
|
56
59
|
return this;
|
|
57
60
|
}
|
|
58
61
|
/**
|
|
@@ -61,16 +64,16 @@ class Cursor {
|
|
|
61
64
|
* @return {Cursor} Returns the cursor, so you can chain this call.
|
|
62
65
|
*/
|
|
63
66
|
limit(n) {
|
|
64
|
-
this
|
|
67
|
+
this.#operators.push({ $limit: n });
|
|
65
68
|
return this;
|
|
66
69
|
}
|
|
67
70
|
/**
|
|
68
71
|
* Returns results ordered according to a sort specification.
|
|
69
|
-
* @param {
|
|
72
|
+
* @param {AnyObject} modifier an object of key and values specifying the sort order. 1 for ascending and -1 for descending
|
|
70
73
|
* @return {Cursor} Returns the cursor, so you can chain this call.
|
|
71
74
|
*/
|
|
72
75
|
sort(modifier) {
|
|
73
|
-
this
|
|
76
|
+
this.#operators.push({ $sort: modifier });
|
|
74
77
|
return this;
|
|
75
78
|
}
|
|
76
79
|
/**
|
|
@@ -78,20 +81,19 @@ class Cursor {
|
|
|
78
81
|
* @param {*} spec
|
|
79
82
|
*/
|
|
80
83
|
collation(spec) {
|
|
81
|
-
this
|
|
84
|
+
this.#options = { ...this.#options, collation: spec };
|
|
82
85
|
return this;
|
|
83
86
|
}
|
|
84
87
|
/**
|
|
85
88
|
* Returns the next document in a cursor.
|
|
86
|
-
* @returns {
|
|
89
|
+
* @returns {AnyObject | Boolean}
|
|
87
90
|
*/
|
|
88
91
|
next() {
|
|
89
|
-
if (this
|
|
90
|
-
return this
|
|
92
|
+
if (this.#buffer.length > 0) {
|
|
93
|
+
return this.#buffer.pop();
|
|
91
94
|
}
|
|
92
95
|
const o = this.fetch().next();
|
|
93
|
-
if (o.done)
|
|
94
|
-
return;
|
|
96
|
+
if (o.done) return;
|
|
95
97
|
return o.value;
|
|
96
98
|
}
|
|
97
99
|
/**
|
|
@@ -99,12 +101,10 @@ class Cursor {
|
|
|
99
101
|
* @returns {boolean}
|
|
100
102
|
*/
|
|
101
103
|
hasNext() {
|
|
102
|
-
if (this
|
|
103
|
-
return true;
|
|
104
|
+
if (this.#buffer.length > 0) return true;
|
|
104
105
|
const o = this.fetch().next();
|
|
105
|
-
if (o.done)
|
|
106
|
-
|
|
107
|
-
this.buffer.push(o.value);
|
|
106
|
+
if (o.done) return false;
|
|
107
|
+
this.#buffer.push(o.value);
|
|
108
108
|
return true;
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import "./init/basic";
|
|
2
2
|
import { Aggregator } from "./aggregator";
|
|
3
3
|
import { Query } from "./query";
|
|
4
|
+
import { createUpdater, update } from "./updater";
|
|
4
5
|
import { Aggregator as Aggregator2 } from "./aggregator";
|
|
5
6
|
import { Query as Query2 } from "./query";
|
|
7
|
+
import { createUpdater as createUpdater2, update as update2 } from "./updater";
|
|
6
8
|
function find(collection, criteria, projection, options) {
|
|
7
9
|
return new Query(criteria, options).find(collection, projection);
|
|
8
10
|
}
|
|
@@ -16,14 +18,18 @@ var src_default = {
|
|
|
16
18
|
Aggregator,
|
|
17
19
|
Query,
|
|
18
20
|
aggregate,
|
|
21
|
+
createUpdater,
|
|
19
22
|
find,
|
|
20
|
-
remove
|
|
23
|
+
remove,
|
|
24
|
+
update
|
|
21
25
|
};
|
|
22
26
|
export {
|
|
23
27
|
Aggregator2 as Aggregator,
|
|
24
28
|
Query2 as Query,
|
|
25
29
|
aggregate,
|
|
30
|
+
createUpdater2 as createUpdater,
|
|
26
31
|
src_default as default,
|
|
27
32
|
find,
|
|
28
|
-
remove
|
|
33
|
+
remove,
|
|
34
|
+
update2 as update
|
|
29
35
|
};
|
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useOperators } from "../core";
|
|
2
2
|
import * as booleanOperators from "../operators/expression/boolean";
|
|
3
3
|
import * as comparisonOperators from "../operators/expression/comparison";
|
|
4
4
|
import { $limit, $project, $skip, $sort } from "../operators/pipeline";
|
|
5
5
|
import * as projectionOperators from "../operators/projection";
|
|
6
6
|
import * as queryOperators from "../operators/query";
|
|
7
|
-
useOperators(
|
|
7
|
+
useOperators("expression", {
|
|
8
8
|
...booleanOperators,
|
|
9
9
|
...comparisonOperators
|
|
10
10
|
});
|
|
11
|
-
useOperators(
|
|
11
|
+
useOperators("pipeline", {
|
|
12
12
|
$project,
|
|
13
13
|
$skip,
|
|
14
14
|
$limit,
|
|
15
15
|
$sort
|
|
16
16
|
});
|
|
17
|
-
useOperators(
|
|
18
|
-
useOperators(
|
|
19
|
-
const BASIC_CONTEXT = Context.init().addExpressionOps({
|
|
20
|
-
...booleanOperators,
|
|
21
|
-
...comparisonOperators
|
|
22
|
-
}).addPipelineOps({ $project, $skip, $limit, $sort }).addProjectionOps(projectionOperators).addQueryOps(queryOperators);
|
|
23
|
-
export {
|
|
24
|
-
BASIC_CONTEXT
|
|
25
|
-
};
|
|
17
|
+
useOperators("projection", projectionOperators);
|
|
18
|
+
useOperators("query", queryOperators);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useOperators } from "../core";
|
|
2
2
|
import * as accumulatorOperators from "../operators/accumulator";
|
|
3
3
|
import * as expressionOperators from "../operators/expression";
|
|
4
4
|
import * as pipelineOperators from "../operators/pipeline";
|
|
5
5
|
import * as projectionOperators from "../operators/projection";
|
|
6
6
|
import * as queryOperators from "../operators/query";
|
|
7
7
|
import * as windowOperators from "../operators/window";
|
|
8
|
-
useOperators(
|
|
9
|
-
useOperators(
|
|
10
|
-
useOperators(
|
|
11
|
-
useOperators(
|
|
12
|
-
useOperators(
|
|
13
|
-
useOperators(
|
|
8
|
+
useOperators("accumulator", accumulatorOperators);
|
|
9
|
+
useOperators("expression", expressionOperators);
|
|
10
|
+
useOperators("pipeline", pipelineOperators);
|
|
11
|
+
useOperators("projection", projectionOperators);
|
|
12
|
+
useOperators("query", queryOperators);
|
|
13
|
+
useOperators("window", windowOperators);
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { MingoError } from "./util";
|
|
1
|
+
import { isArray, MingoError } from "./util";
|
|
2
2
|
function Lazy(source) {
|
|
3
3
|
return source instanceof Iterator ? source : new Iterator(source);
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function concat(...iterators) {
|
|
6
6
|
let index = 0;
|
|
7
7
|
return Lazy(() => {
|
|
8
8
|
while (index < iterators.length) {
|
|
9
9
|
const o = iterators[index].next();
|
|
10
|
-
if (!o.done)
|
|
11
|
-
return o;
|
|
10
|
+
if (!o.done) return o;
|
|
12
11
|
index++;
|
|
13
12
|
}
|
|
14
13
|
return { done: true };
|
|
@@ -36,47 +35,42 @@ function createCallback(nextFn, iteratees, buffer) {
|
|
|
36
35
|
let bufferIndex = 0;
|
|
37
36
|
return function(storeResult) {
|
|
38
37
|
try {
|
|
39
|
-
outer:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
dropItem(iteratees, i);
|
|
65
|
-
continue outer;
|
|
66
|
-
default:
|
|
67
|
-
break outer;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
done = innerDone;
|
|
71
|
-
if (storeResult) {
|
|
72
|
-
buffer[bufferIndex++] = o;
|
|
73
|
-
} else {
|
|
74
|
-
return { value: o, done: false };
|
|
38
|
+
outer: while (!done) {
|
|
39
|
+
let o = nextFn();
|
|
40
|
+
index++;
|
|
41
|
+
let i = -1;
|
|
42
|
+
const size = iteratees.length;
|
|
43
|
+
let innerDone = false;
|
|
44
|
+
while (++i < size) {
|
|
45
|
+
const r = iteratees[i];
|
|
46
|
+
switch (r.action) {
|
|
47
|
+
case 0 /* MAP */:
|
|
48
|
+
o = r.func(o, index);
|
|
49
|
+
break;
|
|
50
|
+
case 1 /* FILTER */:
|
|
51
|
+
if (!r.func(o, index)) continue outer;
|
|
52
|
+
break;
|
|
53
|
+
case 2 /* TAKE */:
|
|
54
|
+
--r.count;
|
|
55
|
+
if (!r.count) innerDone = true;
|
|
56
|
+
break;
|
|
57
|
+
case 3 /* DROP */:
|
|
58
|
+
--r.count;
|
|
59
|
+
if (!r.count) dropItem(iteratees, i);
|
|
60
|
+
continue outer;
|
|
61
|
+
default:
|
|
62
|
+
break outer;
|
|
75
63
|
}
|
|
76
64
|
}
|
|
65
|
+
done = innerDone;
|
|
66
|
+
if (storeResult) {
|
|
67
|
+
buffer[bufferIndex++] = o;
|
|
68
|
+
} else {
|
|
69
|
+
return { value: o, done: false };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
77
72
|
} catch (e) {
|
|
78
|
-
if (e !== DONE)
|
|
79
|
-
throw e;
|
|
73
|
+
if (e !== DONE) throw e;
|
|
80
74
|
}
|
|
81
75
|
done = true;
|
|
82
76
|
return { done };
|
|
@@ -91,8 +85,8 @@ class Iterator {
|
|
|
91
85
|
* @param {Function} fn An optional transformation function
|
|
92
86
|
*/
|
|
93
87
|
constructor(source) {
|
|
94
|
-
this
|
|
95
|
-
this
|
|
88
|
+
this.#iteratees = [];
|
|
89
|
+
this.#yieldedValues = [];
|
|
96
90
|
this.isDone = false;
|
|
97
91
|
let nextVal;
|
|
98
92
|
if (source instanceof Function) {
|
|
@@ -102,17 +96,15 @@ class Iterator {
|
|
|
102
96
|
const src = source;
|
|
103
97
|
nextVal = () => {
|
|
104
98
|
const o = src.next();
|
|
105
|
-
if (o.done)
|
|
106
|
-
throw DONE;
|
|
99
|
+
if (o.done) throw DONE;
|
|
107
100
|
return o.value;
|
|
108
101
|
};
|
|
109
|
-
} else if (source
|
|
102
|
+
} else if (isArray(source)) {
|
|
110
103
|
const data = source;
|
|
111
104
|
const size = data.length;
|
|
112
105
|
let index = 0;
|
|
113
106
|
nextVal = () => {
|
|
114
|
-
if (index < size)
|
|
115
|
-
return data[index++];
|
|
107
|
+
if (index < size) return data[index++];
|
|
116
108
|
throw DONE;
|
|
117
109
|
};
|
|
118
110
|
} else if (!(source instanceof Function)) {
|
|
@@ -120,21 +112,28 @@ class Iterator {
|
|
|
120
112
|
`Lazy must be initialized with an array, generator, or function.`
|
|
121
113
|
);
|
|
122
114
|
}
|
|
123
|
-
this
|
|
115
|
+
this.#getNext = createCallback(
|
|
116
|
+
nextVal,
|
|
117
|
+
this.#iteratees,
|
|
118
|
+
this.#yieldedValues
|
|
119
|
+
);
|
|
124
120
|
}
|
|
121
|
+
#iteratees;
|
|
122
|
+
#yieldedValues;
|
|
123
|
+
#getNext;
|
|
125
124
|
/**
|
|
126
125
|
* Add an iteratee to this lazy sequence
|
|
127
126
|
*/
|
|
128
127
|
push(action, value) {
|
|
129
128
|
if (typeof value === "function") {
|
|
130
|
-
this
|
|
129
|
+
this.#iteratees.push({ action, func: value });
|
|
131
130
|
} else if (typeof value === "number") {
|
|
132
|
-
this
|
|
131
|
+
this.#iteratees.push({ action, count: value });
|
|
133
132
|
}
|
|
134
133
|
return this;
|
|
135
134
|
}
|
|
136
135
|
next() {
|
|
137
|
-
return this
|
|
136
|
+
return this.#getNext();
|
|
138
137
|
}
|
|
139
138
|
// Iteratees methods
|
|
140
139
|
/**
|
|
@@ -170,7 +169,7 @@ class Iterator {
|
|
|
170
169
|
* Returns a new lazy object with results of the transformation
|
|
171
170
|
* The entire sequence is realized.
|
|
172
171
|
*
|
|
173
|
-
* @param {Callback<Source,
|
|
172
|
+
* @param {Callback<Source, Any[]>} fn Tranform function of type (Array) => (Any)
|
|
174
173
|
*/
|
|
175
174
|
transform(fn) {
|
|
176
175
|
const self = this;
|
|
@@ -190,9 +189,9 @@ class Iterator {
|
|
|
190
189
|
*/
|
|
191
190
|
value() {
|
|
192
191
|
if (!this.isDone) {
|
|
193
|
-
this.isDone = this
|
|
192
|
+
this.isDone = this.#getNext(true).done;
|
|
194
193
|
}
|
|
195
|
-
return this
|
|
194
|
+
return this.#yieldedValues;
|
|
196
195
|
}
|
|
197
196
|
/**
|
|
198
197
|
* Execute the funcion for each value. Will stop when an execution returns false.
|
|
@@ -202,10 +201,8 @@ class Iterator {
|
|
|
202
201
|
each(f) {
|
|
203
202
|
for (; ; ) {
|
|
204
203
|
const o = this.next();
|
|
205
|
-
if (o.done)
|
|
206
|
-
|
|
207
|
-
if (f(o.value) === false)
|
|
208
|
-
return false;
|
|
204
|
+
if (o.done) break;
|
|
205
|
+
if (f(o.value) === false) return false;
|
|
209
206
|
}
|
|
210
207
|
return true;
|
|
211
208
|
}
|
|
@@ -243,5 +240,5 @@ class Iterator {
|
|
|
243
240
|
export {
|
|
244
241
|
Iterator,
|
|
245
242
|
Lazy,
|
|
246
|
-
|
|
243
|
+
concat
|
|
247
244
|
};
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
compare as mingoCmp,
|
|
7
7
|
ensureArray,
|
|
8
8
|
flatten,
|
|
9
|
-
getType,
|
|
10
|
-
inArray,
|
|
11
9
|
intersection,
|
|
12
10
|
isArray,
|
|
13
11
|
isBoolean,
|
|
@@ -20,13 +18,10 @@ import {
|
|
|
20
18
|
isOperator,
|
|
21
19
|
isRegExp,
|
|
22
20
|
isString,
|
|
23
|
-
MAX_INT,
|
|
24
|
-
MAX_LONG,
|
|
25
|
-
MIN_INT,
|
|
26
|
-
MIN_LONG,
|
|
27
21
|
MingoError,
|
|
28
22
|
resolve,
|
|
29
|
-
truthy
|
|
23
|
+
truthy,
|
|
24
|
+
typeOf
|
|
30
25
|
} from "../util";
|
|
31
26
|
function createQueryOperator(predicate) {
|
|
32
27
|
const f = (selector, value, options) => {
|
|
@@ -47,13 +42,10 @@ function createExpressionOperator(predicate) {
|
|
|
47
42
|
};
|
|
48
43
|
}
|
|
49
44
|
function $eq(a, b, options) {
|
|
50
|
-
if (isEqual(a, b))
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
return
|
|
54
|
-
if (a instanceof Array) {
|
|
55
|
-
const eq = isEqual.bind(null, b);
|
|
56
|
-
return a.some(eq) || flatten(a, options?.depth).some(eq);
|
|
45
|
+
if (isEqual(a, b)) return true;
|
|
46
|
+
if (isNil(a) && isNil(b)) return true;
|
|
47
|
+
if (isArray(a)) {
|
|
48
|
+
return a.some((v) => isEqual(v, b)) || flatten(a, options?.depth).some((v) => isEqual(v, b));
|
|
57
49
|
}
|
|
58
50
|
return false;
|
|
59
51
|
}
|
|
@@ -61,8 +53,7 @@ function $ne(a, b, options) {
|
|
|
61
53
|
return !$eq(a, b, options);
|
|
62
54
|
}
|
|
63
55
|
function $in(a, b, options) {
|
|
64
|
-
if (isNil(a))
|
|
65
|
-
return b.some((v) => v === null);
|
|
56
|
+
if (isNil(a)) return b.some((v) => v === null);
|
|
66
57
|
return intersection([ensureArray(a), b], options?.hashFunction).length > 0;
|
|
67
58
|
}
|
|
68
59
|
function $nin(a, b, options) {
|
|
@@ -99,11 +90,10 @@ function $all(values, queries, options) {
|
|
|
99
90
|
}
|
|
100
91
|
let matched = true;
|
|
101
92
|
for (const query of queries) {
|
|
102
|
-
if (!matched)
|
|
103
|
-
|
|
104
|
-
if (isObject(query) && inArray(Object.keys(query), "$elemMatch")) {
|
|
93
|
+
if (!matched) break;
|
|
94
|
+
if (isObject(query) && Object.keys(query).includes("$elemMatch")) {
|
|
105
95
|
matched = $elemMatch(values, query["$elemMatch"], options);
|
|
106
|
-
} else if (query
|
|
96
|
+
} else if (isRegExp(query)) {
|
|
107
97
|
matched = values.some((s) => typeof s === "string" && query.test(s));
|
|
108
98
|
} else {
|
|
109
99
|
matched = values.some((v) => isEqual(query, v));
|
|
@@ -135,22 +125,14 @@ function $elemMatch(a, b, options) {
|
|
|
135
125
|
return false;
|
|
136
126
|
}
|
|
137
127
|
const isNull = (a) => a === null;
|
|
138
|
-
const isInt = (a) => isNumber(a) && a >= MIN_INT && a <= MAX_INT && a.toString().indexOf(".") === -1;
|
|
139
|
-
const isLong = (a) => isNumber(a) && a >= MIN_LONG && a <= MAX_LONG && a.toString().indexOf(".") === -1;
|
|
140
128
|
const compareFuncs = {
|
|
141
129
|
array: isArray,
|
|
142
|
-
bool: isBoolean,
|
|
143
130
|
boolean: isBoolean,
|
|
144
131
|
date: isDate,
|
|
145
|
-
decimal: isNumber,
|
|
146
|
-
double: isNumber,
|
|
147
|
-
int: isInt,
|
|
148
|
-
long: isLong,
|
|
149
132
|
number: isNumber,
|
|
150
133
|
null: isNull,
|
|
151
134
|
object: isObject,
|
|
152
135
|
regex: isRegExp,
|
|
153
|
-
regexp: isRegExp,
|
|
154
136
|
string: isString,
|
|
155
137
|
// added for completeness
|
|
156
138
|
undefined: isNil,
|
|
@@ -170,8 +152,8 @@ const compareFuncs = {
|
|
|
170
152
|
9: isDate,
|
|
171
153
|
10: isNull,
|
|
172
154
|
11: isRegExp,
|
|
173
|
-
16:
|
|
174
|
-
18:
|
|
155
|
+
16: isNumber,
|
|
156
|
+
18: isNumber,
|
|
175
157
|
19: isNumber
|
|
176
158
|
//decimal
|
|
177
159
|
};
|
|
@@ -180,10 +162,10 @@ function compareType(a, b, _) {
|
|
|
180
162
|
return f ? f(a) : false;
|
|
181
163
|
}
|
|
182
164
|
function $type(a, b, options) {
|
|
183
|
-
return
|
|
165
|
+
return isArray(b) ? b.findIndex((t) => compareType(a, t, options)) >= 0 : compareType(a, b, options);
|
|
184
166
|
}
|
|
185
167
|
function compare(a, b, f) {
|
|
186
|
-
return ensureArray(a).some((x) =>
|
|
168
|
+
return ensureArray(a).some((x) => typeOf(x) === typeOf(b) && f(x, b));
|
|
187
169
|
}
|
|
188
170
|
export {
|
|
189
171
|
$all,
|
|
@@ -7,10 +7,8 @@ function stddev(data, sampled = true) {
|
|
|
7
7
|
);
|
|
8
8
|
}
|
|
9
9
|
function covariance(dataset, sampled = true) {
|
|
10
|
-
if (!dataset)
|
|
11
|
-
|
|
12
|
-
if (dataset.length < 2)
|
|
13
|
-
return sampled ? null : 0;
|
|
10
|
+
if (!dataset) return null;
|
|
11
|
+
if (dataset.length < 2) return sampled ? null : 0;
|
|
14
12
|
let meanX = 0;
|
|
15
13
|
let meanY = 0;
|
|
16
14
|
for (const [x, y] of dataset) {
|
|
@@ -8,8 +8,7 @@ const $accumulator = (collection, expr, options) => {
|
|
|
8
8
|
!!options && options.scriptEnabled,
|
|
9
9
|
"$accumulator operator requires 'scriptEnabled' option to be true"
|
|
10
10
|
);
|
|
11
|
-
if (collection.length == 0)
|
|
12
|
-
return expr.initArgs;
|
|
11
|
+
if (collection.length == 0) return expr.initArgs;
|
|
13
12
|
const copts = ComputeOptions.init(options);
|
|
14
13
|
const initArgs = computeValue(
|
|
15
14
|
{},
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ComputeOptions,
|
|
3
|
+
computeValue
|
|
4
|
+
} from "../../core";
|
|
2
5
|
const $first = (collection, expr, options) => {
|
|
3
|
-
|
|
6
|
+
if (collection.length === 0) return void 0;
|
|
7
|
+
const copts = ComputeOptions.init(options).update(collection[0]);
|
|
8
|
+
return computeValue(collection[0], expr, null, copts);
|
|
4
9
|
};
|
|
5
10
|
export {
|
|
6
11
|
$first
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ComputeOptions,
|
|
3
|
+
computeValue
|
|
4
|
+
} from "../../core";
|
|
2
5
|
const $last = (collection, expr, options) => {
|
|
3
|
-
|
|
6
|
+
if (collection.length === 0) return void 0;
|
|
7
|
+
const obj = collection[collection.length - 1];
|
|
8
|
+
const copts = ComputeOptions.init(options).update(obj);
|
|
9
|
+
return computeValue(obj, expr, null, copts);
|
|
4
10
|
};
|
|
5
11
|
export {
|
|
6
12
|
$last
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { compare,
|
|
1
|
+
import { assert, compare, isArray, isEmpty, isNil } from "../../util";
|
|
2
2
|
import { $push } from "./push";
|
|
3
3
|
const $max = (collection, expr, options) => {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
)
|
|
9
|
-
|
|
4
|
+
const items = $push(collection, expr, options);
|
|
5
|
+
if (isEmpty(items)) return null;
|
|
6
|
+
assert(isArray(items), "$max: input must resolve to array");
|
|
7
|
+
let max = items[0];
|
|
8
|
+
for (const n of items) {
|
|
9
|
+
if (isNil(n) || isNaN(n)) continue;
|
|
10
|
+
if (compare(n, max) >= 0) max = n;
|
|
11
|
+
}
|
|
12
|
+
return max;
|
|
10
13
|
};
|
|
11
14
|
export {
|
|
12
15
|
$max
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { computeValue } from "../../core";
|
|
1
2
|
import { $mergeObjects as __mergeObjects } from "../expression/object/mergeObjects";
|
|
2
|
-
const $mergeObjects = (collection,
|
|
3
|
+
const $mergeObjects = (collection, expr, options) => {
|
|
4
|
+
const arr = computeValue(collection, expr, null, options);
|
|
5
|
+
return __mergeObjects(null, arr, options);
|
|
6
|
+
};
|
|
3
7
|
export {
|
|
4
8
|
$mergeObjects
|
|
5
9
|
};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { compare,
|
|
1
|
+
import { assert, compare, isArray, isEmpty, isNil } from "../../util";
|
|
2
2
|
import { $push } from "./push";
|
|
3
3
|
const $min = (collection, expr, options) => {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const items = $push(collection, expr, options);
|
|
5
|
+
if (isEmpty(items)) return null;
|
|
6
|
+
assert(isArray(items), "$min: input must resolve to array");
|
|
7
|
+
let min = items[0];
|
|
8
|
+
for (const n of items) {
|
|
9
|
+
if (isNil(n) || isNaN(n)) continue;
|
|
10
|
+
if (compare(n, min) <= 0) min = n;
|
|
11
|
+
}
|
|
12
|
+
return min;
|
|
7
13
|
};
|
|
8
14
|
export {
|
|
9
15
|
$min
|
|
@@ -4,8 +4,7 @@ import {
|
|
|
4
4
|
} from "../../core";
|
|
5
5
|
import { isNil } from "../../util";
|
|
6
6
|
const $push = (collection, expr, options) => {
|
|
7
|
-
if (isNil(expr))
|
|
8
|
-
return collection;
|
|
7
|
+
if (isNil(expr)) return collection;
|
|
9
8
|
const copts = ComputeOptions.init(options);
|
|
10
9
|
return collection.map(
|
|
11
10
|
(obj) => computeValue(obj, expr, null, copts.update(obj))
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { isArray, isNumber } from "../../util";
|
|
2
2
|
import { $push } from "./push";
|
|
3
3
|
const $sum = (collection, expr, options) => {
|
|
4
|
-
if (!isArray(collection))
|
|
5
|
-
|
|
6
|
-
if (isNumber(expr))
|
|
7
|
-
return collection.length * expr;
|
|
4
|
+
if (!isArray(collection)) return 0;
|
|
5
|
+
if (isNumber(expr)) return collection.length * expr;
|
|
8
6
|
const nums = $push(collection, expr, options).filter(isNumber);
|
|
9
7
|
return nums.reduce((acc, n) => acc + n, 0);
|
|
10
8
|
};
|