refactor(ivy): remove duplicated flatten util (#29547)
This commit removes code duplication where we had 2 versions of a `flatten` utility. Moreover this change results in queries using a non-recursive version of `flatten` which should result in a better performance of query refresh operations. PR Close #29547
This commit is contained in:

committed by
Miško Hevery

parent
401b8eedd5
commit
dd69e4e780
@ -7,8 +7,6 @@
|
||||
*/
|
||||
|
||||
import {devModeEqual} from '@angular/core/src/change_detection/change_detection_util';
|
||||
|
||||
import {flatten} from '../../src/render3/util/array_utils';
|
||||
import {isDifferent} from '../../src/render3/util/misc_utils';
|
||||
|
||||
describe('util', () => {
|
||||
@ -67,19 +65,4 @@ describe('util', () => {
|
||||
|
||||
});
|
||||
|
||||
describe('flatten', () => {
|
||||
|
||||
it('should flatten an empty array', () => { expect(flatten([])).toEqual([]); });
|
||||
|
||||
it('should flatten a flat array', () => { expect(flatten([1, 2, 3])).toEqual([1, 2, 3]); });
|
||||
|
||||
it('should flatten a nested array', () => {
|
||||
expect(flatten([1, [2], 3])).toEqual([1, 2, 3]);
|
||||
expect(flatten([[1], 2, [3]])).toEqual([1, 2, 3]);
|
||||
expect(flatten([1, [2, [3]], 4])).toEqual([1, 2, 3, 4]);
|
||||
expect(flatten([1, [2, [3]], [4]])).toEqual([1, 2, 3, 4]);
|
||||
expect(flatten([1, [2, [3]], [[[4]]]])).toEqual([1, 2, 3, 4]);
|
||||
expect(flatten([1, [], 2])).toEqual([1, 2]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
25
packages/core/test/util/array_utils_spec.ts
Normal file
25
packages/core/test/util/array_utils_spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {flatten} from '../../src/util/array_utils';
|
||||
|
||||
describe('flatten', () => {
|
||||
|
||||
it('should flatten an empty array', () => { expect(flatten([])).toEqual([]); });
|
||||
|
||||
it('should flatten a flat array', () => { expect(flatten([1, 2, 3])).toEqual([1, 2, 3]); });
|
||||
|
||||
it('should flatten a nested array depth-first', () => {
|
||||
expect(flatten([1, [2], 3])).toEqual([1, 2, 3]);
|
||||
expect(flatten([[1], 2, [3]])).toEqual([1, 2, 3]);
|
||||
expect(flatten([1, [2, [3]], 4])).toEqual([1, 2, 3, 4]);
|
||||
expect(flatten([1, [2, [3]], [4]])).toEqual([1, 2, 3, 4]);
|
||||
expect(flatten([1, [2, [3]], [[[4]]]])).toEqual([1, 2, 3, 4]);
|
||||
expect(flatten([1, [], 2])).toEqual([1, 2]);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user