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

x/revoltio/deps.ts>Collection#partition

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

Partitions the collection into two collections where the first collection contains the items that passed and the second contains the items that failed.

Examples

const [big, small] = collection.partition(guild => guild.memberCount > 250);

Type Parameters

K2 extends K

Parameters

fn: (
value: V,
key: K,
collection: this,
) => key is K2

Function used to test (should return a boolean)

Returns

[Collection<K2, V>, Collection<Exclude<K, K2>, V>]

Type Parameters

V2 extends V

Parameters

fn: (
value: V,
key: K,
collection: this,
) => value is V2

Returns

[Collection<K, V2>, Collection<K, Exclude<V, V2>>]

Parameters

fn: (
value: V,
key: K,
collection: this,
) => boolean

Type Parameters

This
K2 extends K

Parameters

fn: (
this: This,
value: V,
key: K,
collection: this,
) => key is K2
thisArg: This

Returns

[Collection<K2, V>, Collection<Exclude<K, K2>, V>]

Type Parameters

This
V2 extends V

Parameters

fn: (
this: This,
value: V,
key: K,
collection: this,
) => value is V2
thisArg: This

Returns

[Collection<K, V2>, Collection<K, Exclude<V, V2>>]

Parameters

fn: (
this: This,
value: V,
key: K,
collection: this,
) => boolean
thisArg: This