Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/revoltio/src/lib.ts>Collection#partition

No-nonsense Revolt library for nodejs and deno.
Latest
method Collection.prototype.partition
Re-export
import { Collection } from "https://deno.land/x/revoltio@v1.0.0/src/lib.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