Skip to content

Collections

Namespace: Vercel.AI.Util

public static class Collections

Array and property helpers from the AI SDK util package.

Inheritance: object

View source

GetOwn(IDictionary<string, object>?, string?)

Section titled “GetOwn(IDictionary<string, object>?, string?)”
public static object? GetOwn(IDictionary<string, object>? obj, string? key)

Returns an own dictionary entry, or null when the key is absent.

Parameters

Name Type Description
obj IDictionary<string, object>
key string

Returns: object

View source

public static object? GetOwn(DataObject? obj, string? key)

Returns an own property value. Inherited names such as constructor are not returned. Null and undefined objects return null.

Parameters

Name Type Description
obj DataObject
key string

Returns: object

View source

public static int? GetPotentialStartIndex(string? text, string? searchedText)

Largest index where <code class=“paramref”>searchedText</code> occurs, or where a suffix of <code class=“paramref”>text</code> is a prefix of <code class=“paramref”>searchedText</code>. Empty search text returns null.

Parameters

Name Type Description
text string
searchedText string

Returns: int?

View source

public static List<List<T>> SplitArray<T>(IReadOnlyList<T>? array, int chunkSize)

Splits <code class=“paramref”>array</code> into chunks of <code class=“paramref”>chunkSize</code>.

Type parameters

Name Description
T

Parameters

Name Type Description
array IReadOnlyList<T>
chunkSize int

Returns: List<List<T>>

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product