Skip to content

[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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

[BCN] Remove lodash #3889

wants to merge 2 commits into from

Conversation

MicahMaphet
Copy link
Contributor

No description provided.

@kajoseph kajoseph changed the title emoved unused lodash imports in bitcore-node [BCN] Remove unused lodash imports Apr 15, 2025
@MicahMaphet MicahMaphet changed the title [BCN] Remove unused lodash imports [BCN] Remove lodash May 21, 2025
@kajoseph
Copy link
Collaborator

kajoseph commented Jul 9, 2025

@MicahMaphet could you please

  • Pull in latest master to fix the merge conflicts
  • Sign your commits - all commits must be signed for me to merge

object: TObject,
source: TSource,
customizer: MergeCustomizer
): TObject & TSource {
Copy link
Collaborator

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);
Copy link
Collaborator

@kajoseph kajoseph Jul 30, 2025

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());
Copy link
Collaborator

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())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants