federer
Version:
Experiments in asynchronous federated learning and decentralized learning
40 lines • 1.74 kB
TypeScript
/// <reference types="node" />
export declare function convertBufferToArrayBuffer(buffer: Buffer): ArrayBuffer;
/**
* Creates an array that contains numbers between `start` and `end`.
*
* @param start First number of the range (inclusive)
* @param end Last number of the range (inclusive)
*/
export declare function range(start: number, end: number): number[];
/**
* Clamps a value `x` between `min` and `max`.
*/
export declare function clamp(min: number, x: number, max: number): number;
/**
* Zips the values of two arrays together into a single array. The length of the
* output is equal to the length of the shortest of the two arrays.
*/
export declare function zip<T1, T2>(array1: ReadonlyArray<T1>, array2: ReadonlyArray<T2>): Array<[T1, T2]>;
/**
* Groups elements of an array into chunks of the given size. For instance,
* chunking `[1, 2, 3, 4]` into chunks of size 2 returns `[[1, 2], [3, 4]]`.
*/
export declare function chunk<T>(array: T[], size: number): T[][];
/**
* Returns whether the given object is an empty object.
* @see {@link https://stackoverflow.com/q/679915/918389}
*/
export declare function isEmpty(obj: Record<keyof any, any>): boolean;
/**
* Returns the intersection `a ∩ b` of two sets `a` and `b`
*/
export declare function intersection<T>(a: Set<T>, b: Set<T>): Set<T>;
export declare function cumulativeSum(numbers: number[]): number[];
/**
* Partition an array according to a predicate. The items for which the
* predicate is true are in the left position, the items for which the predicate
* is false are in the right position.
*/
export declare function partition<T>(array: T[], predicate: (item: T) => boolean): [true: T[], false: T[]];
//# sourceMappingURL=utils.d.ts.map