Coder Social home page Coder Social logo

Comments (5)

AndreasPizsa avatar AndreasPizsa commented on August 22, 2024

Thank you for opening this issue, @kirbyjs !

You can use an "invalid" thousands delimiter to get the behavior you want:

parseDecimalNumber('1,234,123.12', [null, '.'])
// <- NaN

parseDecimalNumber('1234123.12', [null, '.'])
// <- 1234123.12

Does this solve your issue?

from parse-decimal-number.

kirbyjs avatar kirbyjs commented on August 22, 2024

@AndreasPizsa sorry I didn't completely clarify:

I am currently using cldr with this module. I tried to set group: undefined but it looks like you default to the inOpts.thousand option if inOpts.thousand and inOpts.group is falsey.

cldr doesn't have a thousand property so with the default options here, thousand is still set to ,.

So I could set thousand: undefined as well to get around the issue, but just wanted to check to see that that behavior is the expected behavior.

from parse-decimal-number.

AndreasPizsa avatar AndreasPizsa commented on August 22, 2024

Got it - that makes a lot of sense.

I'll look into it soon; meanwhile, if you want to submit a PR, please feel free to do so!

from parse-decimal-number.

AndreasPizsa avatar AndreasPizsa commented on August 22, 2024

Would this do what you're expecting, @kirbyjs ?

const cldr = require('cldr')
var parseDecimalNumber = require("parse-decimal-number")

const numberSymbols = cldr.extractNumberSymbols('en_US')
parseDecimalNumber("1234123.12", [null, numberSymbols.decimal])
// <- 1234123.12

parseDecimalNumber("1,234,123.12", [null, numberSymbols.decimal])
// <- NaN

https://runkit.com/andreaspizsa/runkit-npm-parse-decimal-number

from parse-decimal-number.

kirbyjs avatar kirbyjs commented on August 22, 2024

Yep, it works! I'm cool with that solution. Thanks a ton @AndreasPizsa!

from parse-decimal-number.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.