| /*! | ||
| * nosh.js v0.1.3 | ||
| * nosh.js v0.2.0 | ||
| * https://github.com/lmk123/noshjs | ||
@@ -198,6 +198,5 @@ * Released under the MIT License. | ||
| * @param {number} [fixed=2] | ||
| * @param [noZero] - 是否去掉末尾的 0 | ||
| * @return {string} | ||
| */ | ||
| var percentage = function (number, fixed, noZero) { | ||
| var percentage = function (number, fixed) { | ||
| if ( fixed === void 0 ) fixed = 2; | ||
@@ -208,6 +207,3 @@ | ||
| var numberString = (number * 100).toFixed(fixed); | ||
| if (noZero) { | ||
| numberString = parseFloat(numberString); | ||
| } | ||
| return numberString + '%' | ||
| return parseFloat(numberString) + '%' | ||
| }; | ||
@@ -214,0 +210,0 @@ |
+3
-7
| /*! | ||
| * nosh.js v0.1.3 | ||
| * nosh.js v0.2.0 | ||
| * https://github.com/lmk123/noshjs | ||
@@ -194,6 +194,5 @@ * Released under the MIT License. | ||
| * @param {number} [fixed=2] | ||
| * @param [noZero] - 是否去掉末尾的 0 | ||
| * @return {string} | ||
| */ | ||
| var percentage = function (number, fixed, noZero) { | ||
| var percentage = function (number, fixed) { | ||
| if ( fixed === void 0 ) fixed = 2; | ||
@@ -204,8 +203,5 @@ | ||
| var numberString = (number * 100).toFixed(fixed); | ||
| if (noZero) { | ||
| numberString = parseFloat(numberString); | ||
| } | ||
| return numberString + '%' | ||
| return parseFloat(numberString) + '%' | ||
| }; | ||
| export { extend, copy, get, isNumber, kmbt, thousands, obj2qs, remove, percentage }; |
+3
-7
| /*! | ||
| * nosh.js v0.1.3 | ||
| * nosh.js v0.2.0 | ||
| * https://github.com/lmk123/noshjs | ||
@@ -200,6 +200,5 @@ * Released under the MIT License. | ||
| * @param {number} [fixed=2] | ||
| * @param [noZero] - 是否去掉末尾的 0 | ||
| * @return {string} | ||
| */ | ||
| var percentage = function (number, fixed, noZero) { | ||
| var percentage = function (number, fixed) { | ||
| if ( fixed === void 0 ) fixed = 2; | ||
@@ -210,6 +209,3 @@ | ||
| var numberString = (number * 100).toFixed(fixed); | ||
| if (noZero) { | ||
| numberString = parseFloat(numberString); | ||
| } | ||
| return numberString + '%' | ||
| return parseFloat(numberString) + '%' | ||
| }; | ||
@@ -216,0 +212,0 @@ |
+2
-2
| /*! | ||
| * nosh.js v0.1.3 | ||
| * nosh.js v0.2.0 | ||
| * https://github.com/lmk123/noshjs | ||
| * Released under the MIT License. | ||
| */ | ||
| !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.nosh=e.nosh||{})}(this,function(e){"use strict";function n(e){if(Array.isArray(e)){var t=[];return e.forEach(function(e,r){t[r]=n(e)}),t}return"object"==typeof e&&e?r({},e):e}function r(e,r){for(var t in r)a.call(r,t)&&(e[t]=n(r[t]));return e}var t=function(e){return"number"==typeof e&&!isNaN(e)},o=function(e){if(e=Number(e),!t(e))return null;var n=!1,r=String(e);"-"===r[0]&&(n=!0,r=r.slice(1));var o=r.indexOf(".");return{minus:n,integer:o>0?r.slice(0,o):r,decimal:o>0?r.slice(o):""}},i=["","K","M","B","T","P","E"],u=i.length,f=Math.pow(10,3),c=Object.prototype.hasOwnProperty,a=Object.prototype.hasOwnProperty;e.extend=function(e){for(var n=[],t=arguments.length-1;t-- >0;)n[t]=arguments[t+1];return null==e?e:(n.forEach(function(n){null!=n&&r(e,n)}),e)},e.copy=n,e.get=function(e,n,r){if(null==e)return r;var t=e;n=[].concat(n);for(var o=0;o<n.length;o+=1)if(null==(t=t[n[o]]))return r;return t},e.isNumber=t,e.kmbt=function(e,n){void 0===n&&(n=2);var r=o(e);if(!r)return"";var t=Math.min(Math.ceil(r.integer.length/3),u)-1;return Number((e/Math.pow(f,t)).toFixed(n))+i[t]},e.thousands=function(e){var n=o(e);if(!n)return"";for(var r=n.minus,t=n.integer,i=n.decimal,u=t.length,f=Math.ceil(u/3),c=[],a=0;a<f;a++)c.unshift(t.slice(-3*(a+1),u-3*a));return(r?"-":"")+c.join(",")+i},e.obj2qs=function(e){var n=[];for(var r in e)c.call(e,r)&&n.push(r+"="+encodeURIComponent(e[r]));return n.join("&")},e.remove=function(e,n){var r=e.indexOf(n);r>=0&&e.splice(r,1)},e.percentage=function(e,n,r){if(void 0===n&&(n=2),e=Number(e),!t(e))return"";var o=(100*e).toFixed(n);return r&&(o=parseFloat(o)),o+"%"},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
| !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.nosh=e.nosh||{})}(this,function(e){"use strict";function n(e){if(Array.isArray(e)){var t=[];return e.forEach(function(e,r){t[r]=n(e)}),t}return"object"==typeof e&&e?r({},e):e}function r(e,r){for(var t in r)a.call(r,t)&&(e[t]=n(r[t]));return e}var t=function(e){return"number"==typeof e&&!isNaN(e)},o=function(e){if(e=Number(e),!t(e))return null;var n=!1,r=String(e);"-"===r[0]&&(n=!0,r=r.slice(1));var o=r.indexOf(".");return{minus:n,integer:o>0?r.slice(0,o):r,decimal:o>0?r.slice(o):""}},i=["","K","M","B","T","P","E"],u=i.length,f=Math.pow(10,3),c=Object.prototype.hasOwnProperty,a=Object.prototype.hasOwnProperty;e.extend=function(e){for(var n=[],t=arguments.length-1;t-- >0;)n[t]=arguments[t+1];return null==e?e:(n.forEach(function(n){null!=n&&r(e,n)}),e)},e.copy=n,e.get=function(e,n,r){if(null==e)return r;var t=e;n=[].concat(n);for(var o=0;o<n.length;o+=1)if(null==(t=t[n[o]]))return r;return t},e.isNumber=t,e.kmbt=function(e,n){void 0===n&&(n=2);var r=o(e);if(!r)return"";var t=Math.min(Math.ceil(r.integer.length/3),u)-1;return Number((e/Math.pow(f,t)).toFixed(n))+i[t]},e.thousands=function(e){var n=o(e);if(!n)return"";for(var r=n.minus,t=n.integer,i=n.decimal,u=t.length,f=Math.ceil(u/3),c=[],a=0;a<f;a++)c.unshift(t.slice(-3*(a+1),u-3*a));return(r?"-":"")+c.join(",")+i},e.obj2qs=function(e){var n=[];for(var r in e)c.call(e,r)&&n.push(r+"="+encodeURIComponent(e[r]));return n.join("&")},e.remove=function(e,n){var r=e.indexOf(n);r>=0&&e.splice(r,1)},e.percentage=function(e,n){if(void 0===n&&(n=2),e=Number(e),!t(e))return"";var r=(100*e).toFixed(n);return parseFloat(r)+"%"},Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -7,13 +7,9 @@ import isNumber from './isNumber' | ||
| * @param {number} [fixed=2] | ||
| * @param [noZero] - 是否去掉末尾的 0 | ||
| * @return {string} | ||
| */ | ||
| export default function (number, fixed = 2, noZero) { | ||
| export default function (number, fixed = 2) { | ||
| number = Number(number) | ||
| if (!isNumber(number)) return '' | ||
| let numberString = (number * 100).toFixed(fixed) | ||
| if (noZero) { | ||
| numberString = parseFloat(numberString) | ||
| } | ||
| return numberString + '%' | ||
| return parseFloat(numberString) + '%' | ||
| } |
+2
-2
| { | ||
| "name": "noshjs", | ||
| "version": "0.1.3", | ||
| "version": "0.2.0", | ||
| "main": "dist/nosh.common.js", | ||
@@ -16,3 +16,3 @@ "module": "dist/nosh.esm.js", | ||
| "test": "istanbul cover node_modules/jasmine/bin/jasmine.js -- JASMINE_CONFIG_PATH=jasmine.json", | ||
| "prepublish": "yarn test", | ||
| "prepublishOnly": "yarn test", | ||
| "upload-coverage": "cat coverage/lcov.info | node_modules/coveralls/bin/coveralls.js" | ||
@@ -19,0 +19,0 @@ }, |
23930
-1.77%756
-2.07%