feat(core): Add QueryList#forEach
This commit is contained in:
parent
c1a0af514f
commit
b634a25ae0
@ -51,6 +51,11 @@ export class QueryList<T> {
|
|||||||
*/
|
*/
|
||||||
reduce<U>(fn: (acc: U, item: T) => U, init: U): U { return this._results.reduce(fn, init); }
|
reduce<U>(fn: (acc: U, item: T) => U, init: U): U { return this._results.reduce(fn, init); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* executes function for each element in a query.
|
||||||
|
*/
|
||||||
|
forEach(fn: (item: T) => void): void { this._results.forEach(fn); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* converts QueryList into an array
|
* converts QueryList into an array
|
||||||
*/
|
*/
|
||||||
|
@ -50,6 +50,13 @@ export function main() {
|
|||||||
expect(queryList.map((x) => x)).toEqual(['one', 'two']);
|
expect(queryList.map((x) => x)).toEqual(['one', 'two']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should support forEach', () => {
|
||||||
|
queryList.reset(['one', 'two']);
|
||||||
|
let join = '';
|
||||||
|
queryList.forEach((x) => join = join + x);
|
||||||
|
expect(join).toEqual('onetwo');
|
||||||
|
});
|
||||||
|
|
||||||
if (!IS_DART) {
|
if (!IS_DART) {
|
||||||
it('should support filter', () => {
|
it('should support filter', () => {
|
||||||
queryList.reset(['one', 'two']);
|
queryList.reset(['one', 'two']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user