GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix util extend issue by itkoren · Pull Request #2334 · nodejs/node

Conversation

@itkoren

@itkoren itkoren commented Aug 9, 2015

Copy link
Copy Markdown

When the "origin" object argument is null or not defined, _extend
throws exception.
Fix _extend to allow undefined "origin" object argument and return
the "add" object argument.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@itkoren
Fix util extend issue
6028e18
When the "origin" object argument is null or not defined, _extend
throws exception.
Fix _extend to allow undefined "origin" object argument and return
the "add" object argument.
@mscdex mscdex added the util Issues and PRs related to the built-in util module. label Aug 9, 2015
@brendanashworth

brendanashworth commented Aug 9, 2015

Copy link
Copy Markdown
Contributor

Ref: nodejs/node-v0.x-archive#25672

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123 Fishrock123 added semver-major PRs that contain breaking changes and should be released in the next major version. and removed semver-major PRs that contain breaking changes and should be released in the next major version. labels Aug 10, 2015
@ronkorving

ronkorving commented Aug 10, 2015

Copy link
Copy Markdown
Contributor

Should we not be returning a copy of add? (ie: set origin = {}; and letting it run, instead of returning add)
Now you return an object that may or may not be the added object, the user could start mutating it and get unexpected results.

Imho, we should always return origin. If we have no origin, make one.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@itkoren
Always return origin
b9f4597
Fix _extend to allow undefined "origin" object argument and create
a new origin object to return, instead of returning "add" object
argument.
@itkoren

itkoren commented Aug 10, 2015

Copy link
Copy Markdown
Author

I totally agree @ronkorving. I've just pushed a fix for this suggested behavior, so the add object is immutable

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@itkoren
Fix comment to match behavior
4396300
@ronkorving

ronkorving commented Aug 10, 2015

Copy link
Copy Markdown
Contributor

Thanks! 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123

Fishrock123 commented Aug 10, 2015

Copy link
Copy Markdown
Contributor

Is the use case for this just cloning an object, or am I missing something?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

brendanashworth
brendanashworth reviewed Sep 1, 2015
View reviewed changes
Comment thread lib/util.js Outdated

@brendanashworth brendanashworth Sep 1, 2015

Copy link
Copy Markdown
Contributor

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 can see that the above condition uses || typeof add !== 'object', but I'd rather not see that added again down below. util._extend(36, {a: 42}) makes no sense.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cjihrig cjihrig Sep 1, 2015

Copy link
Copy Markdown
Contributor

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 agree with @brendanashworth. util._extend(36, {a: 42}) is nonsensical and should probably blow up.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Fishrock123 Fishrock123 Sep 1, 2015

Copy link
Copy Markdown
Contributor

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.

+1

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@noscripter noscripter Jan 13, 2016

Copy link
Copy Markdown

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.

+1

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@brendanashworth

brendanashworth commented Sep 1, 2015

Copy link
Copy Markdown
Contributor

I'm not sure that this is really pressing enough to be added. util._extend(object || {}, { ... }) seems like it would work fine for your usecase. Plus, util._extend is technically private (even though everyone uses it), so it isn't really designed to be used downstream. Thoughts on that?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rvagg
rvagg force-pushed the master branch from 11c25c2 to ba02bd0 Compare September 6, 2015 11:55
@jasnell jasnell added the stalled Issues and PRs manually marked as stalled and scheduled for automatic closure. label Nov 16, 2015
@jasnell

jasnell commented Nov 16, 2015

Copy link
Copy Markdown
Member

-1 on this. Not seeing the benefit (extending a null or undefined should blow up IMO). given the lack of activity, closing. Can reopen if anyone feel it is necessary.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell jasnell closed this Nov 16, 2015
@cjihrig

cjihrig commented Nov 16, 2015

Copy link
Copy Markdown
Contributor

FWIW, we also have Object.assign() now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronkorving

ronkorving commented Nov 17, 2015

Copy link
Copy Markdown
Contributor

Object.assign is quite slow unfortunately :(

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jan 16, 2022
[Snyk] Security upgrade marked from 0.3.19 to 4.0.10 solebox/node#27
Open
[Snyk] Security upgrade marked from 0.3.19 to 4.0.10 s4sc/node#26
Open
[Snyk] Security upgrade marked from 0.3.6 to 4.0.10 GregorFendt/node#20
Open
[Snyk] Security upgrade marked from 0.3.6 to 4.0.10 saurabharch/node#25
Open
[Snyk] Security upgrade marked from 0.3.6 to 4.0.10 KamilPolivka/node#24
Open
[Snyk] Security upgrade marked from 0.3.19 to 4.0.10 erdun/node#44
Open
[Snyk] Security upgrade marked from 0.3.6 to 4.0.10 saeedahassan/node#38
Open
[Snyk] Security upgrade marked from 0.3.6 to 4.0.10 olegnn/node#38
Open
@snyk-bot snyk-bot mentioned this pull request Jan 31, 2022
[Snyk] Security upgrade marked from 0.3.19 to 4.0.10 enterstudio/node#25
Open
@snyk-bot snyk-bot mentioned this pull request Jun 24, 2022
[Snyk] Fix for 7 vulnerabilities adamlaska/node#70
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

stalled Issues and PRs manually marked as stalled and scheduled for automatic closure. util Issues and PRs related to the built-in util module.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@itkoren @brendanashworth @ronkorving @Fishrock123 @jasnell @cjihrig @noscripter @mscdex
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.