Skip to content

guards.Function.notEmptyAry

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

@zenstone/ts-utils / guards / notEmptyAry

Function: notEmptyAry()

Call Signature

notEmptyAry<T>(val): val is T[]

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

检查值是否为非空数组,支持可选的元素类型守卫

Type Parameters

T

T = unknown

Parameters

val

unknown

任意值

Returns

val is T[]

Example

if (notEmptyAry(value)) {
  console.log(value[0]); // value is unknown[]
}

if (notEmptyAry(value, isStr)) {
  console.log(value[0].toUpperCase()); // value is string[]
}

Call Signature

notEmptyAry<T>(val, guard): val is T[]

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

检查值是否为非空数组,支持可选的元素类型守卫

Type Parameters

T

T

Parameters

val

unknown

任意值

guard

(item) => item is T

可选的元素类型守卫

Returns

val is T[]

Example

if (notEmptyAry(value)) {
  console.log(value[0]); // value is unknown[]
}

if (notEmptyAry(value, isStr)) {
  console.log(value[0].toUpperCase()); // value is string[]
}

Clone this wiki locally