Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/revoltio/deps.ts>Collection#merge

No-nonsense Revolt library for nodejs and deno.
Latest
method Collection.prototype.merge
import { Collection } from "https://deno.land/x/revoltio@v1.0.0/deps.ts";

Merges two Collections together into a new Collection.

Examples

// Sums up the entries in two collections. coll.merge( other, x => ({ keep: true, value: x }), y => ({ keep: true, value: y }), (x, y) => ({ keep: true, value: x + y }), );

// Intersects two collections in a left-biased manner. coll.merge( other, x => ({ keep: false }), y => ({ keep: false }), (x, _) => ({ keep: true, value: x }), );

Parameters

other: ReadonlyCollection<K, T>

The other Collection to merge with

whenInSelf: (value: V, key: K) => Keep<R>

Function getting the result if the entry only exists in this Collection

whenInOther: (valueOther: T, key: K) => Keep<R>

Function getting the result if the entry only exists in the other Collection

whenInBoth: (
value: V,
valueOther: T,
key: K,
) => Keep<R>

Function getting the result if the entry exists in both Collections