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

feat(src): generic exponent plugin #91

Merged
merged 3 commits into from May 21, 2024
Merged

feat(src): generic exponent plugin #91

merged 3 commits into from May 21, 2024

Conversation

pazbardanl
Copy link
Contributor

Types of changes

  • Enhancement (project structure, spelling, grammar, formatting)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

A description of the changes proposed in the Pull Request

  • a generic plugin for exponent operator

@pazbardanl pazbardanl marked this pull request as ready for review May 8, 2024 08:28
@pazbardanl pazbardanl requested a review from jmcook1186 May 8, 2024 08:31
src/lib/exponent/README.md Outdated Show resolved Hide resolved
src/lib/exponent/README.md Outdated Show resolved Hide resolved
src/lib/exponent/README.md Outdated Show resolved Hide resolved
src/lib/exponent/README.md Outdated Show resolved Hide resolved
src/lib/exponent/README.md Outdated Show resolved Hide resolved
src/lib/exponent/README.md Outdated Show resolved Hide resolved
src/lib/exponent/README.md Outdated Show resolved Hide resolved
src/lib/exponent/README.md Outdated Show resolved Hide resolved
src/lib/exponent/index.ts Outdated Show resolved Hide resolved
};

const validateNumericString = (str: string) => {
if (isNaN(+Number(str))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

the condition will be more readable with this typeof str !== 'number'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool. also added a unit test to cover this scenario.
I have to say this was a bit counter intuitive for me: if we pass str as str: string, how come typeof str !== 'number' isn't always true? guess it's one of those unique TypeScript things...

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this change works.

typeof str !== 'number' does not check that the string is numeric, it checks whether the type is a number.

Depending on the purpose of the check, you might want to check that the string parses to a number, or use some regex to check that the string only contains numbers.

@manushak please confirm

Copy link
Contributor

Choose a reason for hiding this comment

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

you're right @jmcook1186 , but shouldn't we require the user to pass a number instead of a string, like this: '10'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jmcook1186 your turn :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @pazbardanl @manushak we should be able to parse numeric strings too. Can you confirm that this is the current behaviour.

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case @pazbardanl, please, use your version

Copy link
Contributor

Choose a reason for hiding this comment

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

done

src/lib/exponent/README.md Outdated Show resolved Hide resolved
src/lib/exponent/README.md Outdated Show resolved Hide resolved
src/lib/exponent/index.ts Outdated Show resolved Hide resolved
Signed-off-by: Paz Barda <paz.barda@intel.com>
@jmcook1186 jmcook1186 added the awaiting-qa PR is waiting for QA approval label May 16, 2024
@jmcook1186 jmcook1186 linked an issue May 20, 2024 that may be closed by this pull request
10 tasks
src/lib/exponent/index.ts Outdated Show resolved Hide resolved
Signed-off-by: Joseph Cook <33655003+jmcook1186@users.noreply.github.com>
Signed-off-by: Joseph Cook <33655003+jmcook1186@users.noreply.github.com>
@jmcook1186 jmcook1186 merged commit 0eb2ea1 into main May 21, 2024
2 checks passed
@jmcook1186 jmcook1186 deleted the generic-exponent branch May 21, 2024 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-qa PR is waiting for QA approval
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Design a generic exponent plugin
3 participants