-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[BCN] Remove lodash #3889
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
base: master
Are you sure you want to change the base?
[BCN] Remove lodash #3889
Conversation
@MicahMaphet could you please
|
object: TObject, | ||
source: TSource, | ||
customizer: MergeCustomizer | ||
): TObject & TSource { |
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.
We actually don't need this fn to be this sophisticated. We're only using it in one place, so we can do a somewhat naive/simple deep merge function. See below
@@ -95,7 +95,7 @@ const Config = function(): ConfigType { | |||
|
|||
let foundConfig = findConfig(); | |||
const mergeCopyArray = (objVal, srcVal) => (objVal instanceof Array ? srcVal : undefined); | |||
config = _.mergeWith(config, foundConfig, mergeCopyArray); | |||
config = mergeWith(config, foundConfig, mergeCopyArray); |
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.
I think we can just do something like this (i have not tested):
function merge(dest: any, src: any) {
for (const key in src) {
if (typeof src[key] === 'object' && src[key] !== null && !Array.isArray(src[key])) {
dest[key] = merge(dest[key], src[key]);
} else {
dest[key] = src[key];
}
}
return dest;
}
config = merge(config, foundConfig);
.map(input => input.toObject()) | ||
.value(); | ||
.flat() | ||
.map(input => input.toObject()); |
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 be condensed to:
(one-liner)
txs.flatMap(tx => tx.inputs.map(input => input.toObject());
(a bit more readable)
txs
.flatMap(tx => tx.inputs)
.map(input => input.toObject())
No description provided.