Skip to content

Commit

Permalink
wip: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
cc-hearts committed May 11, 2024
1 parent f4d1ceb commit fb7f884
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/define.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type fn } from '../typings/helper'
import { type Fn } from '../typings/helper'

type CacheResultFunc = {
_result?: any
Expand All @@ -21,7 +21,7 @@ interface DefineDebounceFn {
* @returns {CacheResultFunc} - The debounce function.
*/
export const defineDebounceFn: DefineDebounceFn = function (
fn: fn,
fn: Fn,
delay = 500,
immediate = false,
) {
Expand Down Expand Up @@ -69,7 +69,7 @@ export function defineOnceFn<T>(fn: (...args: any) => T) {
* @param {number} delay - The delay in milliseconds to wait before the throttled function is called. Default is 500ms.
* @returns {CacheResultFunc} - The throttled function.
*/
export function defineThrottleFn(fn: fn, delay = 500) {
export function defineThrottleFn(fn: Fn, delay = 500) {
let startTimer: number | null = null
let timer: any = null
delay = Math.max(delay, 0)
Expand Down
5 changes: 2 additions & 3 deletions lib/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,13 @@ export function arrayToQueryString(array: Array<unknown>, field: string) {

for (const key in element) {
if (hasOwn(element, key)) {
query += `${prefix}[${index}].${key}=${encodeURIComponent(String(Reflect.get(element, key)))}&`
query += `${prefix}${encodeURIComponent(`[${index}]`)}.${encodeURIComponent(key)}=${encodeURIComponent(String(Reflect.get(element, key)))}&`
}
}

queryString += query.slice(0, -1)
} else {
queryString += `${prefix}[${index}]=${encodeURIComponent(String(element))}&`;

queryString += `${prefix}${encodeURIComponent(`[${index}]`)}=${encodeURIComponent(String(element))}&`;
}
}
});
Expand Down
6 changes: 3 additions & 3 deletions typings/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
*/
export type LiteralUnionTips<T extends U, U> = T | (U & Omit<U, PropertyKey>)

export type getArrayChildItem<T extends Array<any>> = T extends Array<infer r>
export type GetArrayChildItem<T extends Array<any>> = T extends Array<infer r>
? r
: never


export type getPromiseType<T> = T extends Promise<infer R> ? R : T
export type GetPromiseType<T> = T extends Promise<infer R> ? R : T

export type fn = (...args: any) => any
export type Fn = (...args: any) => any

export * from './url'
export * from './valid'

0 comments on commit fb7f884

Please sign in to comment.