當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Equaler.default方法代碼示例

本文整理匯總了TypeScript中equatable.Equaler.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Equaler.default方法的具體用法?TypeScript Equaler.default怎麽用?TypeScript Equaler.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在equatable.Equaler的用法示例。


在下文中一共展示了Equaler.default方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: elementSelector

export function toSet<T>(source: Queryable<T>, elementSelector: ((element: T) => T) | Equaler<T> = identity, equaler?: Equaler<T>): Set<T> | HashSet<T> {
    if (IsEqualer(elementSelector)) {
        equaler = elementSelector;
        elementSelector = identity;
    }
    assert.mustBeQueryable(source, "source");
    assert.mustBeFunction(elementSelector, "elementSelector");
    assert.mustBeEqualerOrUndefined(equaler, "equaler");
    const set = equaler ? new HashSet<T>(equaler) : new Set<T>();
    for (const item of ToIterable(source)) {
        const element = elementSelector(item);
        set.add(element);
    }
    return set;
}
開發者ID:rbuckton,項目名稱:QueryJS,代碼行數:15,代碼來源:toSet.ts

示例2: await

export async function toSetAsync<T>(source: AsyncQueryable<T>, elementSelector: ((element: T) => T | PromiseLike<T>) | Equaler<T> = identity, equaler?: Equaler<T>): Promise<Set<T> | HashSet<T>> {
    if (IsEqualer(elementSelector)) {
        equaler = elementSelector;
        elementSelector = identity;
    }
    assert.mustBeAsyncQueryable<T>(source, "source");
    assert.mustBeFunction(elementSelector, "elementSelector");
    assert.mustBeEqualerOrUndefined(equaler, "equaler");
    const set = equaler ? new HashSet<T>(equaler) : new Set<T>();
    for await (const item of ToPossiblyAsyncIterable(source)) {
        const element = await elementSelector(item);
        set.add(element);
    }
    return set;
}
開發者ID:rbuckton,項目名稱:QueryJS,代碼行數:15,代碼來源:toSetAsync.ts

示例3: keySelector

export function toMap<T, K>(source: Queryable<T>, keySelector: (element: T) => K, elementSelector: ((element: T) => T) | Equaler<K> = identity, keyEqualer?: Equaler<K>): Map<K, T> | HashMap<K, T> {
    if (IsEqualer(elementSelector)) {
        keyEqualer = elementSelector;
        elementSelector = identity;
    }
    assert.mustBeQueryable(source, "source");
    assert.mustBeFunction(keySelector, "keySelector");
    assert.mustBeFunction(elementSelector, "elementSelector");
    assert.mustBeEqualerOrUndefined(keyEqualer, "keyEqualer");
    const map = keyEqualer ? new HashMap<K, T>(keyEqualer) : new Map<K, T>();
    for (const item of ToIterable(source)) {
        const key = keySelector(item);
        const element = elementSelector(item);
        map.set(key, element);
    }
    return map;
}
開發者ID:rbuckton,項目名稱:QueryJS,代碼行數:17,代碼來源:toMap.ts

示例4: await

export async function toMapAsync<T, K>(source: AsyncQueryable<T>, keySelector: (element: T) => K, elementSelector: ((element: T) => T | PromiseLike<T>) | Equaler<K> = identity, keyEqualer?: Equaler<K>): Promise<Map<K, T> | HashMap<K, T>> {
    if (IsEqualer(elementSelector)) {
        keyEqualer = elementSelector;
        elementSelector = identity;
    }
    assert.mustBeAsyncQueryable<T>(source, "source");
    assert.mustBeFunction(keySelector, "keySelector");
    assert.mustBeFunction(elementSelector, "elementSelector");
    assert.mustBeEqualerOrUndefined(keyEqualer, "keyEqualer");
    const map = keyEqualer ? new HashMap<K, T>(keyEqualer) : new Map<K, T>();
    for await (const item of ToPossiblyAsyncIterable(source)) {
        const key = keySelector(item);
        const element = await elementSelector(item);
        map.set(key, element);
    }
    return map;
}
開發者ID:rbuckton,項目名稱:QueryJS,代碼行數:17,代碼來源:toMapAsync.ts


注:本文中的equatable.Equaler.default方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。