mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-16 19:01:05 +00:00
refactor(lib): extract fillArray utility
This commit is contained in:
parent
06e02c3dc3
commit
f3c702947c
7 changed files with 23 additions and 10 deletions
7
src/lib/__tests__/fill-array.spec.js
Normal file
7
src/lib/__tests__/fill-array.spec.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { fillArray } from '../fill-array';
|
||||
|
||||
test('fillArray', () => {
|
||||
expect(fillArray(0)).toEqual([]);
|
||||
expect(fillArray(2)).toEqual([0, 1]);
|
||||
expect(fillArray(3)).toEqual([0, 1, 2]);
|
||||
});
|
5
src/lib/fill-array.js
Normal file
5
src/lib/fill-array.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
function fillArray(length) {
|
||||
return Array.from({ length }, (_, i) => i);
|
||||
}
|
||||
|
||||
export { fillArray };
|
|
@ -1,2 +1,3 @@
|
|||
export { cx } from './cx';
|
||||
export { css } from './css';
|
||||
export { fillArray } from './fill-array';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue