本文整理匯總了TypeScript中rxjs/operators.findIndex函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript findIndex函數的具體用法?TypeScript findIndex怎麽用?TypeScript findIndex使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了findIndex函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should not emit if source does not emit', () => {
const source = hot('-');
const subs = '^';
const expected = '-';
expectObservable(source.pipe(findIndex(truePredicate))).toBe(expected);
expectSubscriptions(source.subscriptions).toBe(subs);
});
示例2: asDiagram
asDiagram('findIndex(x => x % 5 === 0)')('should return matching element from source emits single element', () => {
const values = {a: 3, b: 9, c: 15, d: 20};
const source = hot('---a--b--c--d---|', values);
const subs = '^ ! ';
const expected = '---------(x|) ';
const predicate = function (x: number) { return x % 5 === 0; };
expectObservable(source.pipe(findIndex(predicate))).toBe(expected, { x: 2 });
expectSubscriptions(source.subscriptions).toBe(subs);
});