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

Merge provided context with default context #1953

Closed

Conversation

chriswiggins
Copy link

This addresses issue #1950

My first commit to Hapi so hopefully all is as required. Have included two test cases to ensure this works as expected - 100% test coverage.

Chris

@chriswiggins
Copy link
Author

7c5abe6 did not affect testing - is this something we should be worried about?

Also, build not failing due to my changes - appears to be timeouts.


//Merge the two contexts, using the provided context as source to override the default if requried.
if (context) {
Hoek.merge(defaultContext, context);
Copy link
Contributor

Choose a reason for hiding this comment

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

merge() is not the right tool here because we don't want to create a deep copy of context. Instead we need a shallow copy of the keys. A simple Object.keys(context) with a for loop would be enough.

@hueniverse hueniverse added the feature New functionality or improvement label Sep 16, 2014
@hueniverse hueniverse self-assigned this Sep 16, 2014
@chriswiggins
Copy link
Author

Have fixed as you suggested


//Merge the two contexts, using the provided context as source to override the default if requried.
if (context) {
Object.keys(context).forEach(function(key){
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't allow functional programming in live code (e.g. outside of configuration or startup). It's too slow.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, not sure I understand what you mean? How should I change this?

Copy link
Contributor

Choose a reason for hiding this comment

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

use a for loop instead of forEach.

@hueniverse
Copy link
Contributor

Implemented in vision.

@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New functionality or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants