This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove lodash `without` usage * isNumber * Remove lodash `difference` * Replace lodash isEmpty with type guard * Replace isObject with type guard * remove lodash noop * Replace lodash clamp * replace lodash uniqueId * Remove uniqueId import * Add eslint rule to restrict lodash import * Replace lodash range * Replace lodash has() function Replace lodash has * replace omitby * Replace lodash isEqual with fastDeepEqual * Replace kebabCase with change-case package * Replace lodash camelCase Replace lodash mapKeys with function Move mapkeys to utility Create camelCaseKeys which replaces usage of mapKeys * Replace lodash debounce with custom utiity * replace lodash keyby * Replace lodash pick with native function * Replace lodash cloneDeep with klona * Replace snake case keys package with change case * Replace sortBy with fast sort package * replace isEmpty with type guard * Replace pickBy usage in validation reducer * Replace groupBy usage in search list control * Replace flatten, uniqBy usage in getProducts() * Remove setWith and clone from updateState * Replace custom useThrottle with useThrottledCallback from use-debounce package * onSelectRate can use-debounce * Fix missing flatten * Update assets/js/data/cart/test/push-changes.ts Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com> --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
- Loading branch information
1 parent
1a041fd
commit 680b21c
Showing
61 changed files
with
942 additions
and
1,432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
assets/js/base/components/cart-checkout/product-details/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { camelCase } from 'change-case'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { mapKeys } from './map-keys'; | ||
|
||
export const camelCaseKeys = ( obj: object ) => | ||
mapKeys( obj, ( _, key ) => camelCase( key ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type DebouncedFunction< T extends ( ...args: any[] ) => any > = ( ( | ||
...args: Parameters< T > | ||
) => void ) & { flush: () => void }; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const debounce = < T extends ( ...args: any[] ) => any >( | ||
func: T, | ||
wait: number, | ||
immediate?: boolean | ||
): DebouncedFunction< T > => { | ||
let timeout: ReturnType< typeof setTimeout > | null; | ||
let latestArgs: Parameters< T > | null = null; | ||
|
||
const debounced = ( ( ...args: Parameters< T > ) => { | ||
latestArgs = args; | ||
if ( timeout ) clearTimeout( timeout ); | ||
timeout = setTimeout( () => { | ||
timeout = null; | ||
if ( ! immediate && latestArgs ) func( ...latestArgs ); | ||
}, wait ); | ||
if ( immediate && ! timeout ) func( ...args ); | ||
} ) as DebouncedFunction< T >; | ||
|
||
debounced.flush = () => { | ||
if ( timeout && latestArgs ) { | ||
func( ...latestArgs ); | ||
clearTimeout( timeout ); | ||
timeout = null; | ||
} | ||
}; | ||
|
||
return debounced; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const keyBy = < T >( array: T[], key: keyof T ) => { | ||
return array.reduce( ( acc, value ) => { | ||
const computedKey = key ? String( value[ key ] ) : String( value ); | ||
acc[ computedKey ] = value; | ||
return acc; | ||
}, {} as Record< string, T > ); | ||
}; |
Oops, something went wrong.