UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

21 lines (20 loc) 1.3 kB
/** Returns the first element of an array or null if it doesn't exist. */ export declare const first: <T>(array: T[]) => T | null; /** Returns the last element of an array or null if it doesn't exist. */ export declare const last: <T>(array: T[]) => T | null; /** Sorts in-place using the transformation of each array item. */ export declare const sortBy: <T, S>(array: T[], transform: (item: T) => S) => T[]; /** Groups the elements in the array using the transform. */ export declare const groupBy: <T, S extends string | number | symbol>(array: T[], transform: (item: T) => S) => Record<S, T[]>; /** Iterates over each [previous, current, next] triple. */ export declare const forEachTriple: <T>(array: T[], callback: (triple: [previous: T | null, current: T, next: T | null], meta: { index: number; isFirst: boolean; isLast: boolean; }) => void) => void; /** Returns a new array with unique elements, preserving the order. */ export declare const unique: <T>(array: T[]) => T[]; /** Returns a new array with unique elements based on the transformation, preserving the order. */ export declare const uniqueBy: <T, S>(array: T[], transform: (item: T) => S) => T[]; /** Combines two arrays into an array of tuples. */ export declare const zip: <T, U>(array1: T[], array2: U[]) => [T, U][];