Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

num-tofixed

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

num-tofixed - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

13

dist/index.js

@@ -93,3 +93,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

* @param {Number} digits [必选,小数点后数字的个数]
* @param {Boolean} isRound [可选,格式化时是否四舍五入,默认为true,即进行四舍五入,为false时直接截取,不满足位数的往后补0]
* @param {Boolean} isRound [可选,格式化时是否四舍五入,默认为false,即进行四舍五入,为false时直接截取,不满足位数的往后补0]
* @return {String} [结果]

@@ -101,5 +101,2 @@ */

num += '';
if (isRound === undefined) {
isRound = true;
}

@@ -165,5 +162,5 @@ isRound = Boolean(isRound);

// 缩小10的N次方
while(enlarge.length <= digits){
enlarge = '0' + enlarge;
}
// while(enlarge.length <= digits){
// enlarge = '0' + enlarge;
// }
result = enlarge.substr(0, enlarge.length - digits) + '.' + enlarge.substr(enlarge.length - digits);

@@ -186,2 +183,2 @@ }

/******/ ]);
});
});

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.toFixed=t():e.toFixed=t()}(this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t){e.exports=function(e,t,r){var n=+e>=0;if(e+="",void 0===r&&(r=!0),r=Boolean(r),e=e.replace(/^(?:-|\+)/gi,""),t>20||t<0)throw new RangeError("toFixed() digits argument must be between 0 and 20");if(/^\./gi.test(e)&&(e="0"+e),!/^\d+\.?\d*$/gi.test(e))throw new Error("toFixed() num argument must be a valid num");var o=e.split("."),u="",i=function(e,t){for(var r=0;r<t;r++)e+="0";return e},f=function(e,t){return e.length>=t?e.substr(0,t):i(e,t-e.length)};if(o.length<2)u=o[0]+"."+i("",t);else if(!1===r)u=o[0]+"."+f(o[1],t);else{var s=o[0]+f(o[1],t)+"."+o[1].substr(t);for(s=Math.round(s)+"";s.length<=t;)s="0"+s;u=s.substr(0,s.length-t)+"."+s.substr(s.length-t)}return u=u.replace(/\.$/gi,"").replace(/^\./gi,"0."),u=n?u:"-"+u}}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.toFixed=t():e.toFixed=t()}(this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t){e.exports=function(e,t,r){var n=+e>=0;if(e+="",r=Boolean(r),e=e.replace(/^(?:-|\+)/gi,""),t>20||t<0)throw new RangeError("toFixed() digits argument must be between 0 and 20");if(/^\./gi.test(e)&&(e="0"+e),!/^\d+\.?\d*$/gi.test(e))throw new Error("toFixed() num argument must be a valid num");var o=e.split("."),u="",i=function(e,t){for(var r=0;r<t;r++)e+="0";return e},f=function(e,t){return e.length>=t?e.substr(0,t):i(e,t-e.length)};if(o.length<2)u=o[0]+"."+i("",t);else if(!1===r)u=o[0]+"."+f(o[1],t);else{var s=o[0]+f(o[1],t)+"."+o[1].substr(t);u=(s=Math.round(s)+"").substr(0,s.length-t)+"."+s.substr(s.length-t)}return u=u.replace(/\.$/gi,"").replace(/^\./gi,"0."),u=n?u:"-"+u}}])});
{
"name": "num-tofixed",
"version": "1.0.0",
"version": "1.0.1",
"description": "toFixed with Math.round,fixed the bug of original toFixed function",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -74,4 +74,7 @@ # npm-example组件说明

#### v1.0.1 2018-04-20
- 修正isRound的默认值为false
#### v1.0.0 2018-04-20
- 组件发布

@@ -11,3 +11,3 @@ /**

* @param {Number} digits [必选,小数点后数字的个数]
* @param {Boolean} isRound [可选,格式化时是否四舍五入,默认为true,即进行四舍五入,为false时直接截取,不满足位数的往后补0]
* @param {Boolean} isRound [可选,格式化时是否四舍五入,默认为false,即进行四舍五入,为false时直接截取,不满足位数的往后补0]
* @return {String} [结果]

@@ -19,5 +19,2 @@ */

num += '';
if (isRound === undefined) {
isRound = true;
}

@@ -24,0 +21,0 @@ isRound = Boolean(isRound);

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