Skip to content

Commit

Permalink
fix: remove types from jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
ssi02014 committed Nov 9, 2024
1 parent 4092e55 commit fd7af7e
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 77 deletions.
30 changes: 15 additions & 15 deletions dist/purify.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions dist/purify.es.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const typeErrorCreate = unconstruct(TypeError);
/**
* Creates a new function that calls the given function with a specified thisArg and arguments.
*
* @param {(thisArg: any, ...args: any[]) => T} func - The function to be wrapped and called.
* @returns {(thisArg: any, ...args: any[]) => T} A new function that calls the given function with a specified thisArg and arguments.
* @param func - The function to be wrapped and called.
* @returns A new function that calls the given function with a specified thisArg and arguments.
*/
function unapply(func) {
return function (thisArg) {
Expand All @@ -65,8 +65,8 @@ function unapply(func) {
/**
* Creates a new function that constructs an instance of the given constructor function with the provided arguments.
*
* @param {(...args: any[]) => T} func - The constructor function to be wrapped and called.
* @returns { (...args: any[]) => T} A new function that constructs an instance of the given constructor function with the provided arguments.
* @param func - The constructor function to be wrapped and called.
* @returns A new function that constructs an instance of the given constructor function with the provided arguments.
*/
function unconstruct(func) {
return function () {
Expand All @@ -79,10 +79,10 @@ function unconstruct(func) {
/**
* Add properties to a lookup table
*
* @param {Record<string, any>} set - The set to which elements will be added.
* @param {readonly any[]} array - The array containing elements to be added to the set.
* @param {ReturnType<typeof unapply<string>>} transformCaseFunc - An optional function to transform the case of each element before adding to the set.
* @returns {Record<string, any>} The modified set with added elements.
* @param set - The set to which elements will be added.
* @param array - The array containing elements to be added to the set.
* @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
* @returns The modified set with added elements.
*/
function addToSet(set, array) {
let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
Expand Down Expand Up @@ -112,8 +112,8 @@ function addToSet(set, array) {
/**
* Clean up an array to harden against CSPP
*
* @param {T[]} array - The array to be cleaned.
* @returns {Array<T | null>} The cleaned version of the array
* @param array - The array to be cleaned.
* @returns The cleaned version of the array
*/
function cleanArray(array) {
for (let index = 0; index < array.length; index++) {
Expand All @@ -127,8 +127,8 @@ function cleanArray(array) {
/**
* Shallow clone an object
*
* @param {T} object - The object to be cloned.
* @returns {T} A new object that copies the original.
* @param object - The object to be cloned.
* @returns A new object that copies the original.
*/
function clone(object) {
const newObject = create(null);
Expand All @@ -149,9 +149,9 @@ function clone(object) {
/**
* This method automatically checks if the prop is function or getter and behaves accordingly.
*
* @param {T} object - The object to look up the getter function in its prototype chain.
* @param {string} prop - The property name for which to find the getter function.
* @returns {ReturnType<typeof unapply<any>> | (() => null)} The getter function found in the prototype chain or a fallback function.
* @param object - The object to look up the getter function in its prototype chain.
* @param prop - The property name for which to find the getter function.
* @returns The getter function found in the prototype chain or a fallback function.
*/
function lookupGetter(object, prop) {
while (object !== null) {
Expand Down
30 changes: 15 additions & 15 deletions dist/purify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions dist/purify.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 19 additions & 17 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,32 @@ const typeErrorCreate = unconstruct(TypeError);
/**
* Creates a new function that calls the given function with a specified thisArg and arguments.
*
* @param {(thisArg: any, ...args: any[]) => T} func - The function to be wrapped and called.
* @returns {(thisArg: any, ...args: any[]) => T} A new function that calls the given function with a specified thisArg and arguments.
* @param func - The function to be wrapped and called.
* @returns A new function that calls the given function with a specified thisArg and arguments.
*/
function unapply<T>(func: (thisArg: any, ...args: any[]) => T) {
function unapply<T>(
func: (thisArg: any, ...args: any[]) => T
): (thisArg: any, ...args: any[]) => T {
return (thisArg: any, ...args: any[]): T => apply(func, thisArg, args);
}

/**
* Creates a new function that constructs an instance of the given constructor function with the provided arguments.
*
* @param {(...args: any[]) => T} func - The constructor function to be wrapped and called.
* @returns { (...args: any[]) => T} A new function that constructs an instance of the given constructor function with the provided arguments.
* @param func - The constructor function to be wrapped and called.
* @returns A new function that constructs an instance of the given constructor function with the provided arguments.
*/
function unconstruct<T>(func: (...args: any[]) => T) {
function unconstruct<T>(func: (...args: any[]) => T): (...args: any[]) => T {
return (...args: any[]): T => construct(func, args);
}

/**
* Add properties to a lookup table
*
* @param {Record<string, any>} set - The set to which elements will be added.
* @param {readonly any[]} array - The array containing elements to be added to the set.
* @param {ReturnType<typeof unapply<string>>} transformCaseFunc - An optional function to transform the case of each element before adding to the set.
* @returns {Record<string, any>} The modified set with added elements.
* @param set - The set to which elements will be added.
* @param array - The array containing elements to be added to the set.
* @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
* @returns The modified set with added elements.
*/
function addToSet(
set: Record<string, any>,
Expand Down Expand Up @@ -116,8 +118,8 @@ function addToSet(
/**
* Clean up an array to harden against CSPP
*
* @param {T[]} array - The array to be cleaned.
* @returns {Array<T | null>} The cleaned version of the array
* @param array - The array to be cleaned.
* @returns The cleaned version of the array
*/
function cleanArray<T>(array: T[]): Array<T | null> {
for (let index = 0; index < array.length; index++) {
Expand All @@ -134,8 +136,8 @@ function cleanArray<T>(array: T[]): Array<T | null> {
/**
* Shallow clone an object
*
* @param {T} object - The object to be cloned.
* @returns {T} A new object that copies the original.
* @param object - The object to be cloned.
* @returns A new object that copies the original.
*/
function clone<T extends Record<string, any>>(object: T): T {
const newObject = create(null);
Expand Down Expand Up @@ -164,9 +166,9 @@ function clone<T extends Record<string, any>>(object: T): T {
/**
* This method automatically checks if the prop is function or getter and behaves accordingly.
*
* @param {T} object - The object to look up the getter function in its prototype chain.
* @param {string} prop - The property name for which to find the getter function.
* @returns {ReturnType<typeof unapply<any>> | (() => null)} The getter function found in the prototype chain or a fallback function.
* @param object - The object to look up the getter function in its prototype chain.
* @param prop - The property name for which to find the getter function.
* @returns The getter function found in the prototype chain or a fallback function.
*/
function lookupGetter<T extends Record<string, any>>(
object: T,
Expand Down

0 comments on commit fd7af7e

Please sign in to comment.