findAndSpliceInsert
The findAndSpliceInsert() function searches for the first element that satisfies a predicate and inserts an array of elements at that position without deleting the found element.
Interactive example
Syntax
Classic signature
typescript
function findAndSpliceInsert<
GenericElement extends unknown
>(
input: readonly GenericElement[],
predicate: (
element: GenericElement,
params: { index: number }
) => boolean,
elements: GenericElement[]
): GenericElement[] | undefinedCurried signature
typescript
function findAndSpliceInsert<
GenericElement extends unknown
>(
predicate: (
element: GenericElement,
params: { index: number }
) => boolean,
elements: GenericElement[]
): (input: readonly GenericElement[]) => GenericElement[] | undefinedParameters
input: Original array.predicate: Function determining where to insert.elements: Array of elements to insert before the found element.
Return value
A new array with the inserted elements or undefined if the condition is never satisfied.
