Skip to content

[#2286]: Underscore could use a _.propertyResult#2531

Open
monkpow wants to merge 1 commit intojashkenas:masterfrom
monkpow:master
Open

[#2286]: Underscore could use a _.propertyResult#2531
monkpow wants to merge 1 commit intojashkenas:masterfrom
monkpow:master

Conversation

@monkpow
Copy link
Copy Markdown

@monkpow monkpow commented May 5, 2016

I chose the name _.method per the above suggestion, but am happy to adjust if this does not match the project guidelines.

Fixes #2286

@coveralls
Copy link
Copy Markdown

coveralls commented May 5, 2016

Coverage Status

Coverage increased (+0.03%) to 96.894% when pulling 10bc63e on monkpow:master into 53086b0 on jashkenas:master.

underscore.js Outdated
// referenced object.
_.method = function(value) {
var isFunction = this.isFunction,
rest = this.rest,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

use restArgs instead

@coveralls
Copy link
Copy Markdown

coveralls commented May 5, 2016

Coverage Status

Coverage increased (+0.03%) to 96.894% when pulling 037d5a8 on monkpow:master into 53086b0 on jashkenas:master.

@monkpow
Copy link
Copy Markdown
Author

monkpow commented May 5, 2016

@megawac Thanks for the quality feedback. Updated diff addresses:

  • use restArgs
  • don't use this keyword, use direct reference
  • Clarified comment and token in response to Question: "is this not valid when a function is provided?". Added narrative above in this thread.
  • check if value is a function in the outer function.

underscore.js Outdated

return restArgs(function(obj, args) {
if (obj == null) { return; }
func = isFunctionLiteral ? value : obj[value];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

define func here rather than outer scope

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks, updated diff with this change.

@jdalton
Copy link
Copy Markdown
Contributor

jdalton commented May 5, 2016

fyi lodash/method.

…ctions on an Object. Closes jashkenas#2286: Underscore could use a _.propertyResult.
@coveralls
Copy link
Copy Markdown

coveralls commented May 6, 2016

Coverage Status

Coverage increased (+0.02%) to 96.891% when pulling 3fa1ae3 on monkpow:master into 53086b0 on jashkenas:master.

@jgonggrijp jgonggrijp added the contrib probably belongs in Underscore-contrib label Jan 11, 2021
@jgonggrijp jgonggrijp self-assigned this Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contrib probably belongs in Underscore-contrib enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Underscore could use a _.propertyResult

5 participants