From 98e0837174e9041d87edeb33416de7828ff09867 Mon Sep 17 00:00:00 2001 From: Juhyeok Kang Date: Sun, 9 Jun 2024 21:51:23 +0900 Subject: [PATCH] style(*): Fix missing and incorrect JSDoc types (#30) * style: Add missing return types * style: Fix missing and incorrect JSDoc types * style: remove duplicate asterisks --- src/array/differenceWith.ts | 2 +- src/array/drop.ts | 2 +- src/array/dropRight.ts | 2 +- src/array/dropRightWhile.ts | 4 ++-- src/array/intersectionWith.ts | 2 +- src/array/take.ts | 2 +- src/array/unionBy.ts | 2 +- src/array/uniq.ts | 2 +- src/array/uniqBy.ts | 4 ++++ src/array/uniqWith.ts | 4 ++++ src/array/xorBy.ts | 2 +- src/array/zipWith.ts | 2 +- src/math/clamp.ts | 2 +- src/math/round.ts | 2 +- src/math/sum.ts | 2 +- src/object/omit.ts | 2 +- src/object/pick.ts | 2 +- src/predicate/isNil.ts | 2 +- src/predicate/isNull.ts | 2 +- src/predicate/isUndefined.ts | 2 +- 20 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/array/differenceWith.ts b/src/array/differenceWith.ts index 6df8a6450..ed1fc9233 100644 --- a/src/array/differenceWith.ts +++ b/src/array/differenceWith.ts @@ -13,7 +13,7 @@ * according to the custom equality function. * * @example - * * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }]; + * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }]; * const array2 = [{ id: 2 }, { id: 4 }]; * const areItemsEqual = (a, b) => a.id === b.id; * const result = differenceWith(array1, array2, areItemsEqual); diff --git a/src/array/drop.ts b/src/array/drop.ts index f798e541b..9526c03e2 100644 --- a/src/array/drop.ts +++ b/src/array/drop.ts @@ -9,7 +9,7 @@ * @returns {T[]} A new array with the specified number of elements removed from the start. * * @example - * * const array = [1, 2, 3, 4, 5]; + * const array = [1, 2, 3, 4, 5]; * const result = drop(array, 2); * // result will be [3, 4, 5] since the first two elements are dropped. */ diff --git a/src/array/dropRight.ts b/src/array/dropRight.ts index d4ad41703..03e51a04e 100644 --- a/src/array/dropRight.ts +++ b/src/array/dropRight.ts @@ -9,7 +9,7 @@ * @returns {T[]} A new array with the specified number of elements removed from the end. * * @example - * * const array = [1, 2, 3, 4, 5]; + * const array = [1, 2, 3, 4, 5]; * const result = dropRight(array, 2); * // result will be [1, 2, 3] since the last two elements are dropped. */ diff --git a/src/array/dropRightWhile.ts b/src/array/dropRightWhile.ts index fa5a201af..4b371cea8 100644 --- a/src/array/dropRightWhile.ts +++ b/src/array/dropRightWhile.ts @@ -7,7 +7,7 @@ import { dropWhile } from './dropWhile'; * predicate function returns false. It then returns a new array with the remaining elements. * * @param {T[]} arr - The array from which to drop elements. - * @param {function(item: T): boolean} canContinueDropping - A predicate function that determines + * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines * whether to continue dropping elements. The function is called with each element from the end, * and dropping continues as long as it returns true. * @returns {T[]} A new array with the elements remaining after the predicate returns false. @@ -17,7 +17,7 @@ import { dropWhile } from './dropWhile'; * const result = dropRightWhile(array, x => x > 3); * // result will be [1, 2, 3] since elements greater than 3 are dropped from the end. */ -export function dropRightWhile(arr: T[], canContinueDropping: (item: T) => boolean) { +export function dropRightWhile(arr: T[], canContinueDropping: (item: T) => boolean): T[] { const reversed = arr.slice().reverse(); const dropped = dropWhile(reversed, canContinueDropping); return dropped.slice().reverse(); diff --git a/src/array/intersectionWith.ts b/src/array/intersectionWith.ts index 0631465bf..4190c0987 100644 --- a/src/array/intersectionWith.ts +++ b/src/array/intersectionWith.ts @@ -13,7 +13,7 @@ * @returns {T[]} A new array containing the elements from the first array that have corresponding matches in the second array according to the custom equality function. * * @example - * * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }]; + * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }]; * const array2 = [{ id: 2 }, { id: 4 }]; * const areItemsEqual = (a, b) => a.id === b.id; * const result = intersectionWith(array1, array2, areItemsEqual); diff --git a/src/array/take.ts b/src/array/take.ts index 3f5228249..1b5748c2c 100644 --- a/src/array/take.ts +++ b/src/array/take.ts @@ -20,6 +20,6 @@ * // Returns [1, 2, 3] * take([1, 2, 3], 5); */ -export function take(arr: T[], count: number) { +export function take(arr: T[], count: number): T[] { return arr.slice(0, count); } diff --git a/src/array/unionBy.ts b/src/array/unionBy.ts index 1317d6252..48e876866 100644 --- a/src/array/unionBy.ts +++ b/src/array/unionBy.ts @@ -3,7 +3,7 @@ * * @param {T[]} arr1 - The first array. * @param {T[]} arr2 - The second array. - * @param {function(item: T): U} mapper - The function to map array elements to comparison values. + * @param {(item: T) => U} mapper - The function to map array elements to comparison values. * @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function. * * @example diff --git a/src/array/uniq.ts b/src/array/uniq.ts index 674a08301..d39a1580b 100644 --- a/src/array/uniq.ts +++ b/src/array/uniq.ts @@ -8,7 +8,7 @@ * @returns {T[]} A new array with only unique values from the original array. * * @example - * * const array = [1, 2, 2, 3, 4, 4, 5]; + * const array = [1, 2, 2, 3, 4, 4, 5]; * const result = uniq(array); * // result will be [1, 2, 3, 4, 5] */ diff --git a/src/array/uniqBy.ts b/src/array/uniqBy.ts index 17aba44db..00b3ddc89 100644 --- a/src/array/uniqBy.ts +++ b/src/array/uniqBy.ts @@ -5,6 +5,10 @@ import { uniqWith } from './uniqWith'; * * It filters out elements with the same value, meaning it does not check for duplicates in data types like Objects. * + * @param {T[]} arr - The array to process. + * @param {(item: T) => U} converter - The function used to convert the array elements. + * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the converter function. + * * @example * ```ts * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor); diff --git a/src/array/uniqWith.ts b/src/array/uniqWith.ts index 28e2b7223..00236f8d1 100644 --- a/src/array/uniqWith.ts +++ b/src/array/uniqWith.ts @@ -3,6 +3,10 @@ * * It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them. * + * @param {T[]} arr - The array to process. + * @param {(item1: T, item2: T) => boolean} areItemsEqual - The function used to compare the array elements. + * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the comparator function. + * * @example * ```ts * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1); diff --git a/src/array/xorBy.ts b/src/array/xorBy.ts index 0a47752ec..45533c042 100644 --- a/src/array/xorBy.ts +++ b/src/array/xorBy.ts @@ -12,7 +12,7 @@ import { unionBy } from './unionBy'; * * @param {T[]} arr1 - The first array. * @param {T[]} arr2 - The second array. - * @param {function(item: T): U} mapper - The function to map array elements to comparison values. + * @param {(item: T) => U} mapper - The function to map array elements to comparison values. * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the values returned by the mapping function. * * @example diff --git a/src/array/zipWith.ts b/src/array/zipWith.ts index 3fef7cea5..04d318858 100644 --- a/src/array/zipWith.ts +++ b/src/array/zipWith.ts @@ -8,7 +8,7 @@ * @param {U[]} [arr2] - The second array to zip (optional). * @param {V[]} [arr3] - The third array to zip (optional). * @param {W[]} [arr4] - The fourth array to zip (optional). - * @param {function} combine - The combiner function that takes corresponding elements from each array and returns a single value. + * @param {(...items: T[]) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value. * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays. * * @example diff --git a/src/math/clamp.ts b/src/math/clamp.ts index 83c5c0fc1..9db0f23ee 100644 --- a/src/math/clamp.ts +++ b/src/math/clamp.ts @@ -10,7 +10,7 @@ * @returns {number} The clamped number within the specified bounds. * * @example - * * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5 + * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5 * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15 * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5 * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15 diff --git a/src/math/round.ts b/src/math/round.ts index b2c5b06fd..559ba64b4 100644 --- a/src/math/round.ts +++ b/src/math/round.ts @@ -9,7 +9,7 @@ * @returns {number} The rounded number. * * @example - * * const result1 = round(1.2345); // result1 will be 1 + * const result1 = round(1.2345); // result1 will be 1 * const result2 = round(1.2345, 2); // result2 will be 1.23 * const result3 = round(1.2345, 3); // result3 will be 1.235 */ diff --git a/src/math/sum.ts b/src/math/sum.ts index 084bca4b5..890bef7b2 100644 --- a/src/math/sum.ts +++ b/src/math/sum.ts @@ -7,7 +7,7 @@ * @returns {number} The sum of all the numbers in the array. * * @example - * * const numbers = [1, 2, 3, 4, 5]; + * const numbers = [1, 2, 3, 4, 5]; * const result = sum(numbers); * // result will be 15 */ diff --git a/src/object/omit.ts b/src/object/omit.ts index 5f94d6e8f..7cd0740af 100644 --- a/src/object/omit.ts +++ b/src/object/omit.ts @@ -9,7 +9,7 @@ * @returns {Omit} A new object with the specified keys omitted. * * @example - * * const obj = { a: 1, b: 2, c: 3 }; + * const obj = { a: 1, b: 2, c: 3 }; * const result = omit(obj, ['b', 'c']); * // result will be { a: 1 } */ diff --git a/src/object/pick.ts b/src/object/pick.ts index 07a2f7e94..1ed0bcb4d 100644 --- a/src/object/pick.ts +++ b/src/object/pick.ts @@ -9,7 +9,7 @@ * @returns {Pick} A new object with the specified keys picked. * * @example - * * const obj = { a: 1, b: 2, c: 3 }; + * const obj = { a: 1, b: 2, c: 3 }; * const result = pick(obj, ['a', 'c']); * // result will be { a: 1, c: 3 } */ diff --git a/src/predicate/isNil.ts b/src/predicate/isNil.ts index 80355e3e2..079926534 100644 --- a/src/predicate/isNil.ts +++ b/src/predicate/isNil.ts @@ -10,7 +10,7 @@ * @returns {boolean} `true` if the value is null or undefined, `false` otherwise. * * @example - * * const value1 = null; + * const value1 = null; * const value2 = undefined; * const value3 = 42; * const result1 = isNil(value1); // true diff --git a/src/predicate/isNull.ts b/src/predicate/isNull.ts index b486a8f47..e04084e8b 100644 --- a/src/predicate/isNull.ts +++ b/src/predicate/isNull.ts @@ -10,7 +10,7 @@ * @returns {x is null} True if the value is null, false otherwise. * * @example - * * const value1 = null; + * const value1 = null; * const value2 = undefined; * const value3 = 42; * diff --git a/src/predicate/isUndefined.ts b/src/predicate/isUndefined.ts index caca003f2..8856847bd 100644 --- a/src/predicate/isUndefined.ts +++ b/src/predicate/isUndefined.ts @@ -10,7 +10,7 @@ * @returns {x is undefined} true if the value is undefined, false otherwise. * * @example - * * const value1 = undefined; + * const value1 = undefined; * const value2 = null; * const value3 = 42; *