Skip to content
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

refactor: use different defaultsDeep and clean up some code #206

Merged
merged 1 commit into from
Jun 21, 2018

Conversation

jacobheun
Copy link
Contributor

defaultsDeep

This includes updates to the already changed examples.

This leverages @nodeutils/defaults-deep instead of lodash.defaultsdeep. This ensures that cloning of objects does not happen. This will also make sure that an array passed within options, will not be stomped on by defaults. Passed arrays win over defaults.

Example:

const options = {
  modules: {
    peerDiscovery: [Bootstrap, wsStar.discovery]
  }
}

const defaults = {
  modules: {
    peerDiscovery: [MulticastDNS]
  }
}

return defaultsDeep(options, defaults)

will result in a returned object deeply equivalent to the options.

code updates

  • Clarifies some nested callback naming
  • Removes redundant looping over transports

@ghost ghost assigned jacobheun Jun 20, 2018
@ghost ghost added the status/in-progress In progress label Jun 20, 2018
@jacobheun jacobheun requested a review from daviddias June 20, 2018 17:32
@jacobheun jacobheun mentioned this pull request Jun 20, 2018
3 tasks
@@ -113,7 +113,7 @@ const MPLEX = require('libp2p-mplex')
const SECIO = require('libp2p-secio')
const MulticastDNS = require('libp2p-mdns')
const DHT = require('libp2p-kad-dht')
const defaultsDeep = require('lodash.defaultsdeep')
const defaultsDeep = require('@nodeutils/defaults-deep')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great find!

Copy link
Member

@daviddias daviddias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ Thank you @jacobheun! :)

@daviddias daviddias merged commit d16b7eb into better-opts Jun 21, 2018
@ghost ghost removed the status/in-progress In progress label Jun 21, 2018
@daviddias daviddias deleted the mergeWith/better-opts branch June 21, 2018 09:17
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