Lawtext query
    Preparing search index...

    Class Query<TItem>

    The query object that represents a source list and a filtering criteria.

    フィルタ条件と検索元リストを表すクエリオブジェクト。

    A Query works as an async generator.

    Query は async generator として使用できます。

    const query = new Query(population, criteria);
    for await (const item of query) {
    console.log(item);
    }

    Type Parameters

    • TItem

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    • Instanciate a Query.

      Type Parameters

      • TItem

      Parameters

      • population: AsyncIterable<TItem>

        a source list

      • criteria: QueryCriteria<TItem> | null

        a filtering criteria

      • Optionaloptions: Partial<QueryOptions>

        options

      Returns Query<TItem>

    Methods

    • Apply a function for each filtered item and iterate the merged object with the returned and original object.

      フィルタ後の要素ごとに関数を実行し、返り値と元の要素のプロパティをマージしたオブジェクトを列挙します。

      Type Parameters

      • T

      Parameters

      • func: (item: TItem) => T | Promise<T>

        a function to be called for each filtered item
        要素ごとに実行される関数

      • Optionalcriteria: QueryCriteria<T extends void | undefined ? never : T & TItem> | null

        an additional criteria applied after merge / マージ後に適用するフィルタ条件

      • Optionaloptions: Partial<QueryOptions>

        options which override the original ones / 上書きするオプション項目

      Returns Query<T extends void | undefined ? never : T & TItem>

      • a new Query that yields merged objects
        マージされたオブジェクトを列挙する新しい Query
    • Apply an additional filter.

      フィルタを追加します。

      Parameters

      • criteria: QueryCriteria<TItem> | null

        an additional criteria / 追加するフィルタ条件

      • Optionaloptions: Partial<QueryOptions>

        options which override the original ones / 上書きするオプション項目

      Returns this

      • a new Query that applies criteria to the filtered items of the original Query
        フィルタ後の項目を検索元とし、criteria を検索条件とする新しい Query
    • Invoke func for each filtered item. Running this function will invoke the whole iteration process of the Query.

      列挙された要素ごとに func を実行します。この関数を実行すると Query の列挙を最後まで実行します。

      Parameters

      • func: (item: TItem) => unknown

        a function to be called for each item
        要素ごとに実行される関数

      Returns Promise<void>

    • Yield until it reaches the maximum count.

      出力の最大件数を設定します。

      Parameters

      • max: number

        the maximum count
        最大件数

      • Optionaloptions: Partial<QueryOptions>

        options which override the original ones / 上書きするオプション項目

      Returns this

      • a new Query that yields until it reaches the maximum count.
        最大件数に達するまで列挙を続ける新しい Query
    • Apply a function for each filtered item.

      フィルタ後の要素ごとに関数を実行します。

      Type Parameters

      • T
      • TRet = T extends void | undefined ? never : T

      Parameters

      • func: (item: TItem) => T | Promise<T>

        a function to be called for each filtered item
        要素ごとに実行される関数

      • Optionalcriteria: QueryCriteria<TRet> | null

        an additional criteria applied after filtering / 関数実行後に適用するフィルタ条件

      • Optionaloptions: Partial<QueryOptions>

        options which override the original ones / 上書きするオプション項目

      Returns Query<Awaited<TRet>>

      • a new Query that yields items returned by func
        func の返り値を列挙する新しい Query
    • Pick properties of each item.

      特定のプロパティ以外のプロパティを削除したオブジェクトを列挙します。

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • ...keys: K[]

        the keys of properties to be picked
        抜き出すプロパティのキー

      Returns Query<Awaited<Pick<TItem, K>>>

      • a new Query that yields the objects with the picked properties
        プロパティを抜き出した新しいオブジェクトの内容を列挙する新しい Query
    • Yield a property of each item.

      特定のプロパティの内容を一つ抜き出して列挙します。

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

        the key of a property to be picked
        抜き出すプロパティのキー

      Returns Query<Awaited<TItem[K]>>

      • a new Query that yields the picked property
        抜き出したプロパティの内容を列挙する新しい Query
    • Skip specified count.

      指定した件数スキップします。

      Parameters

      • count: number

        count to skip
        スキップする件数

      • Optionaloptions: Partial<QueryOptions>

        options which override the original ones / 上書きするオプション項目

      Returns this

      • a new Query that yields after skipping specified count.
        指定した件数のスキップ後列挙を続ける新しい Query
    • Generate an array from the Query. Running this function will invoke the whole iteration process of the Query.

      Query から配列を生成します。この関数を実行すると Query の列挙を最後まで実行します。

      Parameters

      • Optionaloptions: { preserveCache: boolean }

        options.preserveCache <boolean>: whether to suggest the Query to preserve the cached data for each item, which normally will be cleared after yield (default: false)
        Queryにキャッシュされたデータを削除せずそのまま残すかどうかを指示します。

      Returns Promise<TItem[]>

      • a Promise that resolves a generated array
        生成された配列を返す Promise
    • Yield while func returns true.

      functrue を返す間、列挙を続けます。

      Parameters

      • func: (item: TItem) => boolean | Promise<boolean>

        a function to be called for each filtered item. Returning false terminates the iteration.
        要素ごとに実行される関数。falseを返すと列挙を停止します。

      • OptionalyieldLast: boolean

        whether to return the item that caused func returned false
        funcfalseを返す要因となった要素を出力するかどうか

      • Optionaloptions: Partial<QueryOptions>

        options which override the original ones / 上書きするオプション項目

      Returns this

      • a new Query that yields while func returns true
        functrue を返す間列挙を続ける新しい Query