openharmony 鸿蒙 arkts-apis-arkts-collections-Types

2026-08-25 浏览 (1)

Types

NOTE

  • The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.

  • This module can be imported only to ArkTS files (with the file name extension .ets).

ISendable

type ISendable = lang.ISendable

ISendable is the parent type of all sendable types except null and undefined. It does not have any necessary methods or properties.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Utils.Lang

TypeDescription
lang.ISendableParent type of all sendable types.

ArrayFromMapFn18+

type ArrayFromMapFn<FromElementType, ToElementType> = (value: FromElementType, index: number) => ToElementType

Defines the ArkTS Array reduction function, which is used by the from API of the Array class.

System capability: SystemCapability.Utils.Lang

Atomic service API: This API can be used in atomic services since API version 18.

Parameters

NameTypeMandatoryDescription
valueFromElementTypeYesElement that is being processed.
indexnumberYesIndex of the element in the ArkTS array.

Return value

TypeDescription
ToElementTypeResult of the reduction function, which is used as a new element in the array.

ArrayPredicateFn18+

type ArrayPredicateFn<ElementType, ArrayType> = (value: ElementType, index: number, array: ArrayType) => boolean

Defines the ArkTS Array reduction function, which is used by the some and every APIs of the Array class to determine whether array elements meet certain test conditions.

System capability: SystemCapability.Utils.Lang

Atomic service API: This API can be used in atomic services since API version 18.

Parameters

NameTypeMandatoryDescription
valueElementTypeYesElement that is being processed.
indexnumberYesIndex of the element in the ArkTS array.
arrayArrayTypeYesArkTS array that is being traversed.

Return value

TypeDescription
booleanResult of the reduction function, indicating whether the current element meets the test condition. The value true means that the current element or a previous element meets the condition, and false means that no element meets the condition.

ArrayReduceCallback18+

type ArrayReduceCallback<AccType, ElementType, ArrayType> = (previousValue: AccType, currentValue: ElementType, currentIndex: number, array: ArrayType) => AccType

Defines the ArkTS Array reduction function, which is used by the reduceRight API of the Array class.

System capability: SystemCapability.Utils.Lang

Atomic service API: This API can be used in atomic services since API version 18.

Parameters

NameTypeMandatoryDescription
previousValueAccTypeYesAccumulated value of the current traversal.
currentValueElementTypeYesElement that is being traversed in the ArkTS array.
currentIndexnumberYesIndex of the element in the ArkTS array.
arrayArrayTypeYesArkTS array that is being traversed.

Return value

TypeDescription
AccTypeResult of the reduction function, which is used as the previousValue parameter in the next call of ArrayReduceCallback.

TypedArrayFromMapFn

type TypedArrayFromMapFn<FromElementType, ToElementType> = (value: FromElementType, index: number) => ToElementType

Describes the mapping function of the ArkTS TypedArray.

System capability: SystemCapability.Utils.Lang

Atomic service API: This API can be used in atomic services since API version 12.

Parameters

NameTypeMandatoryDescription
valueFromElementTypeYesElement that is currently traversed and used to construct an ArkTS TypedArray.
indexnumberYesIndex of the element, beginning at 0.

Return value

TypeDescription
ToElementTypeElement value after the mapping.

TypedArrayPredicateFn

type TypedArrayPredicateFn<ElementType, ArrayType> = (value: ElementType, index: number, array: ArrayType) => boolean

Describes the assertion function of the ArkTS TypedArray.

System capability: SystemCapability.Utils.Lang

Atomic service API: This API can be used in atomic services since API version 12.

Parameters

NameTypeMandatoryDescription
valueElementTypeYesElement that is being traversed in the ArkTS TypedArray.
indexnumberYesIndex of the element, beginning at 0.
arrayArrayTypeYesArkTS TypedArray that is being traversed.

Return value

TypeDescription
booleanOperation result. The value true is returned if the value meets the condition; otherwise, false is returned.

TypedArrayForEachCallback

type TypedArrayForEachCallback<ElementType, ArrayType> = (value: ElementType, index: number, array: ArrayType) => void

Describes the traversal function of the ArkTS TypedArray.

System capability: SystemCapability.Utils.Lang

Atomic service API: This API can be used in atomic services since API version 12.

Parameters

NameTypeMandatoryDescription
valueElementTypeNoElement that is being traversed in the ArkTS TypedArray.
indexnumberNoIndex of the element, beginning at 0.
arrayArrayTypeNoArkTS TypedArray that is being traversed.

TypedArrayMapCallback

type TypedArrayMapCallback<ElementType, ArrayType> = (value: ElementType, index: number, array: ArrayType) => ElementType

Describes the conversion mapping function of the ArkTS TypedArray.

System capability: SystemCapability.Utils.Lang

Atomic service API: This API can be used in atomic services since API version 12.

Parameters

NameTypeMandatoryDescription
valueElementTypeYesElement that is being mapped in the ArkTS TypedArray.
indexnumberYesIndex of the element, beginning from 0.
arrayArrayTypeYesArkTS TypedArray that is being mapped.

Return value

TypeDescription
ElementTypeElement value after the mapping.

TypedArrayReduceCallback

type TypedArrayReduceCallback<AccType, ElementType, ArrayType> = (previousValue: AccType, currentValue: ElementType, currentIndex: number, array: ArrayType) => AccType

Describes the reduce function of the ArkTS TypedArray.

System capability: SystemCapability.Utils.Lang

Atomic service API: This API can be used in atomic services since API version 12.

Parameters

NameTypeMandatoryDescription
previousValueAccTypeYesAccumulated value of the current traversal.
currentValueElementTypeYesElement that is being traversed in the ArkTS TypedArray.
currentIndexnumberYesIndex of the element, beginning at 0.
arrayArrayTypeYesArkTS TypedArray that is being traversed.

Return value

TypeDescription
AccTypeResult of the reduce function. The result is passed in to the previousValue parameter when TypedArrayReduceCallback is called next time.

TypedArrayCompareFn

type TypedArrayCompareFn<ElementType> = (first: ElementType, second: ElementType) => number

Describes the sort function of the ArkTS TypedArray.

System capability: SystemCapability.Utils.Lang

Atomic service API: This API can be used in atomic services since API version 12.

Parameters

NameTypeMandatoryDescription
firstElementTypeYesFirst element to be compared.
secondElementTypeYesSecond element to be compared.

Return value

TypeDescription
numberComparison result of the elements. If first is less than second, the return value is a negative number. If first is greater than second, the return value is a positive number. If first is equal to second, the return value is 0.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 arkts-apis-arkts-collections-Float32Array

openharmony 鸿蒙 arkts-apis-arkts-collections-ArrayBuffer

openharmony 鸿蒙 js-apis-lightweightset

openharmony 鸿蒙 errorcode-source-obfuscation

openharmony 鸿蒙 arkts-apis-arkts-utils-ASON

openharmony 鸿蒙 arkts-apis-arkts-collections-Uint8ClampedArray

openharmony 鸿蒙 errorcode-tsc

openharmony 鸿蒙 js-apis-deque

openharmony 鸿蒙 arkts-apis-arkts-collections-BitVector

openharmony 鸿蒙 js-apis-worker

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/Hn2TIuFs