-
Notifications
You must be signed in to change notification settings - Fork 512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: remove lodash as a dependency #2378
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
abfec18
feat: remove lodash as a dependency
ckniffen 0dc7611
fix some linting issues
ckniffen 26979ce
fix linting errors
ckniffen cf8b48b
feat: bump typescript to 5.x (#2387)
ckniffen 75bbffd
Merge branch '3.0' into feature/remove-lodash
ckniffen 031d93a
cleanup config files and package.json
ckniffen ba9d0a6
feat: remove node 14 support (#2386)
ckniffen 1c813b5
Merge branch '3.0' into feature/remove-lodash
ckniffen 23ed021
Merge branch '3.0' into feature/remove-lodash
ckniffen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,52 @@ | ||
type ValueOf<T> = T[keyof T] | ||
|
||
/** | ||
* Creates an object composed of keys generated from the results of running each element of collection thru iteratee. | ||
* The order of grouped values is determined by the order they occur in collection. | ||
* The corresponding value of each key is an array of elements responsible for generating the key. | ||
* | ||
* Similar to lodash's groupBy | ||
* | ||
* @param array - array to iterate over | ||
* @param iteratee - function that returns key of the group to place the item | ||
* | ||
* @returns a map of arrays | ||
*/ | ||
export function groupBy<T>( | ||
array: T[], | ||
iteratee: (value: T, index: number, array: T[]) => string, | ||
): { [p: string]: T[] } { | ||
// eslint-disable-next-line max-params -- need all the params for the fallback | ||
return array.reduce<{ [key: string]: T[] }>(function predicate( | ||
acc, | ||
value, | ||
index, | ||
arrayReference, | ||
) { | ||
;(acc[iteratee(value, index, arrayReference)] ||= []).push(value) | ||
return acc | ||
}, | ||
{}) | ||
} | ||
|
||
/** | ||
* Creates an object composed of the own and inherited enumerable string keyed properties of object that | ||
* predicate doesn't return truthy for. | ||
* | ||
* @param obj - Object to have properties removed. | ||
* @param predicate - function that returns whether the property should be removed from the obj. | ||
* | ||
* @returns object | ||
*/ | ||
export function omitBy<T extends object>( | ||
obj: T, | ||
predicate: (objElement: ValueOf<T>, k: string | number | symbol) => boolean, | ||
): Partial<T> { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- We know the keys are properties of T | ||
const keys: Array<keyof T> = Object.keys(obj) as Array<keyof T> | ||
const keysToKeep = keys.filter((kb) => !predicate(obj[kb], kb)) | ||
return keysToKeep.reduce((acc: Partial<T>, key: keyof T) => { | ||
acc[key] = obj[key] | ||
return acc | ||
}, {}) | ||
} | ||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add unit tests for these helper functions?