Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Refactor createMathOperation method to use convertToNumberOrString utility#5919

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
saddamhr wants to merge435 commits intolodash:main
base:main
Choose a base branch
Loading
fromsaddamhr:refactor/createmathoperation-method-with-utility-converter

Conversation

saddamhr
Copy link

Summary

This PR refactors thecreateMathOperation method to improve its code structure by introducing theconvertToNumberOrString utility function. The changes ensure that type conversion logic is abstracted into a separate helper function, improving readability and maintainability.

Changes

  • Replaced in-line type-checking and conversion logic increateMathOperation with theconvertToNumberOrString utility.
  • Preserved original behavior for handling string concatenation and number addition.
  • Ensured that undefined values are handled as per the original logic.

Test Plan

All existing unit tests for theadd method have been executed successfully to confirm that functionality remains intact.

  • add(6, 4) returns10
  • add('6', '4') returns'64'
  • Proper handling ofundefined values and mixed input types.

This refactor maintains backward compatibility while cleaning up the code.

falsyvaluesand others added30 commitsMarch 12, 2017 19:53
One example now shows that specifying a padding length of less than thelength of the string returns the entire original string.
falsyvaluesand others added29 commitsNovember 6, 2019 21:02
Since `function flow(funcs)` changed to `function flow(...funcs)` this ternary became unnecessary, since funcs will always have a length now.
The return type should be `boolean` instead of `number`
Remove the unused param `hash` from the jsdoc of `Hash#delete`
…dash#4681)--save is a command-line option and it should be monospacedCo-authored-by: utkarsh-kukreti <utkarshk@dewsolutions.in>
The `opt-cli` pre-push functionality was removed from lodash just a few daysafter it was added (seelodash@2cd12c3),but the documentation encouraging contributors to use it still remains.Remove to avoid confusion for new contributors.
The master branch has been in flux for a pretty long time, so leavingthe broken npm scripts and messages in CONTRIBUTING.md doesn't makesense and has been confusing to contributors. This commit removes brokennpm scripts and removes all unnecessary dependencies for now.
I've commented out a test for `_.merge` and will re-look it as Igradually cleanup the codebase.
`npm cit` is short for `npm ci` and `npm test`
Signed-off-by: tison <wander4096@gmail.com>
* test: fix throttle.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix pickBy.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix isBuffer.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: partially fix attempt.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: partially fix dropRightWhile.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix defer.spec.js and rest.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix invoke.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix isArray.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: partially fix iteration-methods.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix xor-methods.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix property.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix ary.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix omit-methods.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix debounce-and-throttle.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix unzip-and-zip.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix toPairs-methods.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix exit-early.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: temporarily comment out takeWhile and dropWhile testsSigned-off-by: tison <wander4096@gmail.com>* test: partially fix union*.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix startsWith-and-endsWith.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix isNil.spec.jsSigned-off-by: tison <wander4096@gmail.com>* test: fix some of syntax errorsSigned-off-by: tison <wander4096@gmail.com>---------Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

91 participants
@saddamhr@jdalton@Antti@radekk@aymericbeaumet@ribizli@falsyvalues@kibertoad@scplay@eran-nussbaum@DavidWesley@Andrik264@huangrijian@102@merriam@captbaritone@greenberga@prtksxna@hargasinski@jisaacks@aretecode@MingYinLv@nullvariable@rssteffey@chriscalo@drabinowitz@LukasDrgon@younesfkihi@matthewdordal@yuxino@nazar-pc@timdorr@kybetter@GCHQDeveloper500@TheLarkInn@AlexanderLukin@mattlubner@Crysinyan@JoosAI@jnfingerle@PxyUp@Dean177@alirezavalizade@pahomov@joyeecheung@misogl@ecbrodie@ryanhomer@twolfson@ycmjason@renjithspace@doug-a-brunner@cooperka@dracos@abdullahtariq1171@j3bb9z@alireza-mh@saravyas@blikblum@asilinwei@moonformeli@43081j@carbureted@bnjmnt4n@stevemoser@gu-xionghong@dwelle@futurist@tkrugg@lvzhenbang@Jack-Works@lirantal@phapdinh@Mohit21GoJs@anatoliisf@megawac@prog1dev@camjc@RajuPedda@gwwar@dwesty17@Keith-CY@fs-projects@thxiami@csojinb@de-ar@jacob-lcs@tisonkun@jinbekim@ygj6@KEHyeon

[8]ページ先頭

©2009-2025 Movatter.jp