Skip to content
On this page

Home > @taiyuuki/utils > search_range

search_range() function

This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

在数字区间列表中搜索数字所处的区间

Signature:

typescript
declare function search_range(n: number, ranges: (string | number)[]): MathRange | null;
declare function search_range(n: number, ranges: (string | number)[]): MathRange | null;

Parameters

ParameterTypeDescription
nnumber要搜索的数字
ranges(string | number)[]数字区间列表,例如:['[0, 10]', '(10, 20]', '(20, 30]'],注意开闭区间,且各区间不要有重叠。

Returns:

MathRange | null

搜索结果是一个 Range 对象,如果没有找到则返回 null

Released under the MIT License.