Git Product home page Git Product logo

wnumb's People

Contributors

daverayment avatar leongersen avatar tannerhodges avatar tseabra-rocket avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wnumb's Issues

Reduce package size

Package contains unnecessary file - test.html. I can do PR if your accept this issue.

Formatting large numbers

@leongersen should there be an easier way to format large numbers?

Numeral.js uses a format string -- the 0.00a format on 1234567.89 will output 1.23m. Producing the same output with wNumb would require a custom encoder / decoder.

Should / could this be built into wNumb? Maybe a format option that accepts values "number (default)" or "large_number"?

`suffix` not working, but `postfix` does

Hi Leon, cool library! I just noticed that suffix appears to not work, but postfix does.

Here is my source from an implementation of your noUISlider.

var tooltipFormat = wNumb({
  decimals: 0,
  decoder: function(number){
    return number * 1000;
  },
  encoder: function(number){
    return number / 1000;
  },
  prefix: "$",
  postfix: "k"
})

var salaryRangeSlider = $("#my-slider")[0];
noUiSlider.create(salaryRangeSlider, {
  start: [10000, 225000],
  connect: true,
  tooltips: [tooltipFormat, tooltipFormat],
  range: {
    "min": [10000, 10000],
    "64%": [100000, 25000],
    "max": [250000]
  }
});

Everything looks good in the tooltip, and it says $200k. However, when the postfix above is changed to suffix the k is never output into the tooltip.

Let me know if you would like more info!

Regards,
W

Illegal Activity

Your subdomain is being misused for the promotion of illegal gambling sites in Indonesia. url : depo25bonus25.refreshless.com

Register with Bower?

Hi there,

I'm currently using your nouislider which is registered on bower but I can't find the wnumb formatter extension on there.

Is there any chance you can register that one too?

Thanks :)

James

Uncaught TypeError

Uncaught TypeError: (intermediate value)(intermediate value)(...) is not a function

Steps not working correctly with noUiSlider

I'm using this library together with noUiSlider and sometimes the steps are not correctly applied. I defined a step of 250. That essentially works for most numbers, but sometimes is off by 1:

Screenshot 2023-01-02 at 11 18 05

Even if I type 2.500 into the field, it is "corrected" and jumps back to 2.499.

The next step works just fine though:

Screenshot 2023-01-02 at 11 18 25

Like I said, this happens to some values, but not all. Here I should not be able to slide to that value but to 29.250.

Screenshot 2023-01-02 at 11 24 09

This is the current setup:

var rangeSlider = document.getElementById('slider-range');
var inputFormat = document.getElementById('input-format');

noUiSlider.create(rangeSlider, {
    start: [250],
    tooltips: [true],
    step: 250,
    range: {
        'min': [250],
        'max': [{{ $canInvestMax }}]
    },
    format: wNumb({
        thousand: '.',
        suffix: ' EUR'
    })
});

rangeSlider.noUiSlider.on('update', function (values, handle) {
    inputFormat.value = values[handle];
});

inputFormat.addEventListener('change', function () {
    rangeSlider.noUiSlider.set(this.value);
});

When I remove this part, the error does not occur:

format: wNumb({
    thousand: '.',
    suffix: ' EUR'
})

And idea how to fix that? Both scripts are up-to-date. Testet with Safari and Chrome on macOS.

Strip decimals if double zeros

Is there an option to use 2 decimals but strip the decimals if they are double zeros .00?

So something like 125.00 would output 125 but 125.50 would output 125.50.

Edit
Sorry didn't notice the edit option, was trying to use the encoder option. Here is how I solved it if this helps anyone else.

const moneyFormat = wNumb({
  prefix: '$',
  thousand: ',',
  decimals: 2,
  edit: function(value) {
    return value.replace(/\.00/g, '')
  }
})

Strict formatting

Hi,

I found your library to be extremely useful, except for one case that doesn't really have a solution without doing some hacky stuff that i hate. I need a way to allow strict matching of numbers (when other characters are present

var doubleFormat = wNumb({ mark: ',', thousand: '.', decimals: 2 }); console.log(doubleFormat.from('thisStillReturnsAValidNumber1.231,1231'));

I would like an option such that the previous code returns the text itself, not just the number from it, since it cannot be directly converted to a number.

incorrect decimals: 0 behaviour

I guess there is mistake in the code, in case of decimals set to 0.

    // Reduce the number of decimals to the specified option.
    if ( decimals ) {
        input = toFixed( input, decimals );
    }

And the fix:
// Reduce the number of decimals to the specified option.
if ( typeof decimals != 'undefined') {
input = toFixed( input, decimals );
}

Correct me, if i'm wrong. Thanks.

Rounding issue

Data
I have the following value going into wNumb: 8.905

Format
Here is the wNum function setup:

moneyFormat: wNumb({ mark: ".", thousand: ",", decimals: 2, prefix: "$", postfix: "" }),

Expected Result
I am expecting $8.91 as the output value

Actual Result
I am getting $8.90 as the output value

To me this seems like an issue where it is not rounding correctly with 5 as the 3rd decimal digit I would expect it to round the 2nd digit to 1 instead of leave at 0 since I am specifying 2 Decimal places.

Interestingly, wNumb does a better job of rounding than C# does but it is always cases like this that do not round correctly #.#5 where # is a digit

Thoughts?

wNumb decimal doesn't work :(

wNumb decimal doesn't work :( , i set decimal options with 0/false , and he return for example: 2.9999999, 5.99999996 ....

numbers with more then 16 digits cause some strange roundings

var moneyWithDecimalMarks = wNumb({
thousand: ''',
});

1234567890123456: 1'234'567'890'123'456
12345678901234567: 12'345'678'901'234'568
123456789012345678: 123'456'789'012'345'680
1234567890123456789: 1'234'567'890'123'456'800

The first one is still correct but adding more numbers results in strange effects.

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.