Skip to content

guards.Function.aryGuard

github-actions[bot] edited this page Jun 8, 2026 · 2 revisions

@zenstone/ts-utils / guards / aryGuard

Function: aryGuard()

aryGuard<T>(guard): TypeGuard<T[]>

Defined in: src/guards/index.ts:411

柯里化的数组类型守卫

Type Parameters

T

T

Parameters

guard

(item) => item is T

元素类型守卫

Returns

TypeGuard<T[]>

数组类型守卫函数

Example

const isStrAry = aryGuard(isStr);

if (isStrAry(value)) {
  // value is string[]
}

// 配合 and 使用
const isNonEmptyStrAry = and(isStrAry, (arr) => arr.length > 0);

Clone this wiki locally