@univerjscorefunctionsSearcharray

@univerjs/core v0.5.0-beta.1Docs


Function: searchArray()

function searchArray(
   arr, 
   target, 
   firstMatch): number

Find value in the data that is just greater than the target; if there are equal values greater than the target, select the last one. If firstMatch is true, then return the index of the first number greater than the target. see #univer/pull/3903

Parameters

ParameterTypeDefault valueDescription
arrnumber[]undefinedascending array
targetnumberundefinedvalue wants to find
firstMatchbooleanfalseif true, return the first match when value > target in the array, otherwise return the last value > target. if not match,

Returns

number

index

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/array-search.ts:143