Comments (5)
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.
@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.
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.
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.
Yep, it works! I'm cool with that solution. Thanks a ton @AndreasPizsa!
from parse-decimal-number.
Related Issues (10)
- Add Locale Data HOT 2
- License issue HOT 2
- The default regexp doesn't support negative numbers HOT 2
- Does this work in browsers?
- Dependency on node.js
- Dependency deprecation warning: coffee-script (npm)
- Dependency deprecation warning: gulp-uglifyjs (npm)
- Dependency deprecation warning: gulp-util (npm)
- Function returns a number when it should return NaN
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parse-decimal-number.