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

since version 1.1.1, string "0" returns number 0 without taking into account options #12

Open
pabloblazq opened this issue Feb 25, 2025 · 1 comment

Comments

@pabloblazq
Copy link

pabloblazq commented Feb 25, 2025

Hi,

The following code was returning "string" (no conversion was done) until version 1.0.5 (included)

import toNumber from 'strnum'

const num = toNumber('0', { leadingZeros: false, skipLike: /.*/ })
console.log(typeof num)

But since 1.1.1 the conversion is done not taking into account 'leadingZeros' and/or 'skipLike' options.

Could someone take a look at it? My code depends on fast-xml-parser (not directly to strnum) what makes it complicated a workaround into my solution. In the meantime I need to set my dependency to the concrete version '1.0.5' of strnum.

Thanks in advance!

@amitguptagwl
Copy link
Member

amitguptagwl commented Feb 25, 2025

Ideally, setting leading zero to false should not make any change in the result. Because, single zero is a valid number. skiplike option is impacted. That I've fixed. but not released yet.

Let me know if any other observation. So I'll fix them in minor version and release both packages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants