Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 435 commits into
base: main
Choose a base branch
from

Conversation

saddamhr
Copy link

@saddamhr saddamhr commented Sep 7, 2024

Summary

This PR refactors the createMathOperation method to improve its code structure by introducing the convertToNumberOrString 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 in createMathOperation with the convertToNumberOrString 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 the add method have been executed successfully to confirm that functionality remains intact.

  • add(6, 4) returns 10
  • add('6', '4') returns '64'
  • Proper handling of undefined values and mixed input types.

This refactor maintains backward compatibility while cleaning up the code.

falsyvalues and others added 30 commits March 12, 2017 19:53
One example now shows that specifying a padding length of less than the
length of the string returns the entire original string.
falsyvalues and others added 29 commits November 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 monospaced

Co-authored-by: utkarsh-kukreti <[email protected]>
The `opt-cli` pre-push functionality was removed from lodash just a few days
after it was added (see lodash@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 leaving
the broken npm scripts and messages in CONTRIBUTING.md doesn't make
sense and has been confusing to contributors. This commit removes broken
npm scripts and removes all unnecessary dependencies for now.
I've commented out a test for `_.merge` and will re-look it as I
gradually cleanup the codebase.
`npm cit` is short for `npm ci` and `npm test`
* test: fix throttle.spec.js

Signed-off-by: tison <[email protected]>

* test: fix pickBy.spec.js

Signed-off-by: tison <[email protected]>

* test: fix isBuffer.spec.js

Signed-off-by: tison <[email protected]>

* test: partially fix attempt.spec.js

Signed-off-by: tison <[email protected]>

* test: partially fix dropRightWhile.spec.js

Signed-off-by: tison <[email protected]>

* test: fix defer.spec.js and rest.spec.js

Signed-off-by: tison <[email protected]>

* test: fix invoke.spec.js

Signed-off-by: tison <[email protected]>

* test: fix isArray.spec.js

Signed-off-by: tison <[email protected]>

* test: partially fix iteration-methods.spec.js

Signed-off-by: tison <[email protected]>

* test: fix xor-methods.spec.js

Signed-off-by: tison <[email protected]>

* test: fix property.spec.js

Signed-off-by: tison <[email protected]>

* test: fix ary.spec.js

Signed-off-by: tison <[email protected]>

* test: fix omit-methods.spec.js

Signed-off-by: tison <[email protected]>

* test: fix debounce-and-throttle.spec.js

Signed-off-by: tison <[email protected]>

* test: fix unzip-and-zip.spec.js

Signed-off-by: tison <[email protected]>

* test: fix toPairs-methods.spec.js

Signed-off-by: tison <[email protected]>

* test: fix exit-early.spec.js

Signed-off-by: tison <[email protected]>

* test: temporarily comment out takeWhile and dropWhile tests

Signed-off-by: tison <[email protected]>

* test: partially fix union*.spec.js

Signed-off-by: tison <[email protected]>

* test: fix startsWith-and-endsWith.spec.js

Signed-off-by: tison <[email protected]>

* test: fix isNil.spec.js

Signed-off-by: tison <[email protected]>

* test: fix some of syntax errors

Signed-off-by: tison <[email protected]>

---------

Signed-off-by: tison <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.