1
0
mirror of https://github.com/robonen/tools.git synced 2026-03-20 10:54:44 +00:00

feat(monorepo): migrate vue packages and apply oxlint refactors

This commit is contained in:
2026-03-07 18:07:22 +07:00
parent abd6605db3
commit 41d5e18f6b
286 changed files with 10295 additions and 5028 deletions

View File

@@ -34,7 +34,7 @@ describe('cluster', () => {
it('return an empty array if the input array is empty', () => {
const result = cluster([], 3);
expect(result).toEqual([]);
});
});
});

View File

@@ -2,17 +2,17 @@
* @name cluster
* @category Arrays
* @description Cluster an array into subarrays of a specific size
*
*
* @param {Value[]} arr The array to cluster
* @param {number} size The size of each cluster
* @returns {Value[][]} The clustered array
*
*
* @example
* cluster([1, 2, 3, 4, 5, 6, 7, 8], 3) // => [[1, 2, 3], [4, 5, 6], [7, 8]]
*
*
* @example
* cluster([1, 2, 3, 4], -1) // => []
*
*
* @since 0.0.3
*/
export function cluster<Value>(arr: Value[], size: number): Value[][] {

View File

@@ -20,4 +20,4 @@ describe('first', () => {
expect(first([1, 2, 3], 42)).toBe(1);
expect(first(['a', 'b', 'c'], 'default')).toBe('a');
});
});
});

View File

@@ -2,19 +2,19 @@
* @name first
* @category Arrays
* @description Returns the first element of an array
*
*
* @param {Value[]} arr The array to get the first element from
* @param {Value} [defaultValue] The default value to return if the array is empty
* @returns {Value | undefined} The first element of the array, or the default value if the array is empty
*
*
* @example
* first([1, 2, 3]); // => 1
*
*
* @example
* first([]); // => undefined
*
*
* @since 0.0.3
*/
export function first<Value>(arr: Value[], defaultValue?: Value) {
return arr[0] ?? defaultValue;
}
return arr[0] ?? defaultValue;
}

View File

@@ -2,4 +2,4 @@ export * from './cluster';
export * from './first';
export * from './last';
export * from './sum';
export * from './unique';
export * from './unique';

View File

@@ -20,4 +20,4 @@ describe('last', () => {
expect(last([1, 2, 3], 42)).toBe(3);
expect(last(['a', 'b', 'c'], 'default')).toBe('c');
});
});
});

View File

@@ -2,17 +2,17 @@
* @name last
* @section Arrays
* @description Gets the last element of an array
*
*
* @param {Value[]} arr The array to get the last element of
* @param {Value} [defaultValue] The default value to return if the array is empty
* @returns {Value | undefined} The last element of the array, or the default value if the array is empty
*
*
* @example
* last([1, 2, 3, 4, 5]); // => 5
*
*
* @example
* last([], 3); // => 3
*
*
* @since 0.0.3
*/
export function last<Value>(arr: Value[], defaultValue?: Value) {

View File

@@ -15,7 +15,7 @@ describe('sum', () => {
});
it('return the sum of all elements using a getValue function', () => {
const result = sum([{ value: 1 }, { value: 2 }, { value: 3 }], (item) => item.value);
const result = sum([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value);
expect(result).toBe(6);
});
@@ -39,8 +39,8 @@ describe('sum', () => {
});
it('handle arrays with a getValue function returning floating point numbers', () => {
const result = sum([{ value: 1.5 }, { value: 2.5 }, { value: 3.5 }], (item) => item.value);
const result = sum([{ value: 1.5 }, { value: 2.5 }, { value: 3.5 }], item => item.value);
expect(result).toBe(7.5);
});
});
});

View File

@@ -2,16 +2,16 @@
* @name sum
* @category Arrays
* @description Returns the sum of all the elements in an array
*
*
* @param {Value[]} array - The array to sum
* @param {(item: Value) => number} [getValue] - A function that returns the value to sum from each element in the array
* @returns {number} The sum of all the elements in the array
*
*
* @example
* sum([1, 2, 3, 4, 5]) // => 15
*
*
* sum([{ value: 1 }, { value: 2 }, { value: 3 }], (item) => item.value) // => 6
*
*
* @since 0.0.3
*/
export function sum<Value extends number>(array: Value[]): number;

View File

@@ -11,7 +11,7 @@ describe('unique', () => {
it('return an array with unique objects based on id', () => {
const result = unique(
[{ id: 1 }, { id: 2 }, { id: 1 }],
(item) => item.id,
item => item.id,
);
expect(result).toEqual([{ id: 1 }, { id: 2 }]);
@@ -33,7 +33,7 @@ describe('unique', () => {
const sym1 = Symbol('a');
const sym2 = Symbol('b');
const result = unique([sym1, sym2, sym1]);
expect(result).toEqual([sym1, sym2]);
});
@@ -42,4 +42,4 @@ describe('unique', () => {
expect(result).toEqual([]);
});
});
});

View File

@@ -5,17 +5,17 @@ export type Extractor<Value, Key extends UniqueKey> = (value: Value) => Key;
* @name unique
* @category Arrays
* @description Returns a new array with unique values from the original array
*
*
* @param {Value[]} array - The array to filter
* @param {Function} [extractor] - The function to extract the value to compare
* @returns {Value[]} - The new array with unique values
*
*
* @example
* unique([1, 2, 3, 3, 4, 5, 5, 6]) //=> [1, 2, 3, 4, 5, 6]
*
*
* @example
* unique([{ id: 1 }, { id: 2 }, { id: 1 }], (a, b) => a.id === b.id) //=> [{ id: 1 }, { id: 2 }]
*
*
* @since 0.0.3
*/
export function unique<Value, Key extends UniqueKey>(