New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

number-display

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

number-display - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0

9

CHANGELOG.md

@@ -79,2 +79,9 @@ ## 1.0.0

- Change back param precision name to 'decimal', to avoid confusion with the common 'toPrecision' meaning.
- Add inner precision limit to avoid float error.
- Add inner precision limit to avoid float error.
## 2.2.0
**2020-01-08**
- Add built-in types for Typescript.
- Update license to 2020.

3

package.json
{
"name": "number-display",
"version": "2.1.2",
"version": "2.2.0",
"description": "Display number smartly within a certain length.",
"main": "index.js",
"types": "index.d.ts",
"files": [

@@ -7,0 +8,0 @@ "index.js"

@@ -10,10 +10,10 @@ # number-display

To display data in a width-limited component, this function will smartly help you to convert number to a certain chart length. To be **simple**, **plain**, **flexible** and **accurate**, the conversion follow this rules:
The conversion follow this rules:
- result char length will never overflow length, unless the length setting is too small(< 5).
- replace null or wrong type inputs ( null/NaN/object ) to placeholder
- result char length will never overflow `length` .
- replace null or wrong type inputs ( undefined / NaN / object ) to placeholder
- use locale string with commas ( 1,234,222 ) as possible ( configurable )
- trim number with units ( 1.23k ) when length is limited
- convert scientific notation ( 1.23e+4 ) to friendly form
- directly return input text if allowed
- directly return input text if ( configurable )
- when omitting decimals, you can change the rounding type, default to 'round'

@@ -23,8 +23,2 @@ - no decimal tailing zeros

**Blogs**:
[En](https://medium.com/front-end-weekly/displaying-numbers-in-frontend-2336323493c2)
[中文](https://zhuanlan.zhihu.com/p/85536865)
## Install

@@ -38,4 +32,6 @@

In version 2.\* we only export a `createDisplay` function for users to custom their `display` function. So the real display function has only one input: `value` . This separates the configuration and usage, which is more simple and clear.
*We have built-in types, so Typescript is supported*
We only export a `createDisplay` function for users to custom their `display` function. So the real display function has only one input: `value` . This separates the configuration and usage, which is more simple and clear.
```

@@ -104,3 +100,3 @@ import createDisplay from 'number-display';

The max length the result would be. length should no less then 5 so that any number can display ( say -123000 ) after trim.
The max length the result would be. length should be longer then 5 so that any number can display ( say -123000 ) after trim, or you may get a console warning and length overflow.

@@ -135,2 +131,8 @@ **decimal**

The rounding type when omitting decimals, enum in 'round', 'floor' or 'ceil'.
The rounding type when omitting decimals, enum in 'round', 'floor' or 'ceil'.
## Blogs
[En](https://medium.com/front-end-weekly/displaying-numbers-in-frontend-2336323493c2)
[中文](https://zhuanlan.zhihu.com/p/85536865)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc