number-to-decimal-form-string-x
Version:
Convert a base-10 or scientific E-notation value to a decimal form string.
15 lines • 8.37 kB
JavaScript
/*!
{
"author": "Graham Fairweather",
"copywrite": "Copyright (c) 2017-present",
"date": "2019-08-28T17:15:11.333Z",
"describe": "",
"description": "Convert a base-10 or scientific E-notation value to a decimal form string.",
"file": "number-to-decimal-form-string-x.min.js",
"hash": "f315294f76220dda53fb",
"license": "MIT",
"version": "2.1.2"
}
*/
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.numberToDecimalFormStringX=n():t.numberToDecimalFormStringX=n()}(function(){"use strict";var t,n={}.constructor,r=n.prototype,e=n.defineProperty,o=function(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0},u=function(){return this};try{return e?e(r,"$$globalThis$$",{get:u,configurable:!0}):r.__defineGetter__("$$globalThis$$",u),t="undefined"==typeof $$globalThis$$?o():$$globalThis$$,delete r.$$globalThis$$,t}catch(t){return o()}}(),function(){return function(t){var n={};function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=n,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,n){if(1&n&&(t=r(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)r.d(e,o,function(n){return t[n]}.bind(null,o));return e},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=5)}([function(t,n,r){"use strict";var e=Object.prototype.toString;if(r(2)()){var o=Symbol.prototype.toString,u=/^Symbol\(.*\)$/;t.exports=function(t){if("symbol"==typeof t)return!0;if("[object Symbol]"!==e.call(t))return!1;try{return function(t){return"symbol"==typeof t.valueOf()&&u.test(o.call(t))}(t)}catch(t){return!1}}}else t.exports=function(t){return!1}},function(t,n,r){"use strict";var e=String.prototype.valueOf,o=Object.prototype.toString,u="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){return"string"==typeof t||"object"==typeof t&&(u?function(t){try{return e.call(t),!0}catch(t){return!1}}(t):"[object String]"===o.call(t))}},function(t,n,r){"use strict";(function(n){var e=n.Symbol,o=r(4);t.exports=function(){return"function"==typeof e&&("function"==typeof Symbol&&("symbol"==typeof e("foo")&&("symbol"==typeof Symbol("bar")&&o())))}}).call(this,r(3))},function(t,n){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,n,r){"use strict";t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},n=Symbol("test"),r=Object(n);if("string"==typeof n)return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(n in t[n]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var e=Object.getOwnPropertySymbols(t);if(1!==e.length||e[0]!==n)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,n))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(t,n);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},function(t,n,r){"use strict";r.r(n);var e=r(0),o=r.n(e),u="Cannot convert a Symbol value to a string",i=u.constructor,f=function(t){if(o()(t))throw new TypeError(u);return i(t)};function c(t){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var l=function(t){return"object"===c(t)?null===t:"function"!=typeof t},p=r(1),a=r.n(p),y={}.constructor("a"),s="a"===y[0]&&0 in y,b=function(){}.bind,h="function"==typeof b&&function(){var t=null,n=null,r=null,e=[];try{var o=b.apply(function(e,o){return r=this,t=e,n=o,arguments},[e,1]),u=o(2);return 1===o.length&&2===u.length&&1===t&&2===n&&r===e}catch(t){return!1}}()&&function(){var t=null,n=null,r=null,e=[1,2,3],o=function(o,u){return t=o,n=u,r=this,e};try{var u=b.apply(o,[null]),i=new u(1,2);return u.length===o.length&&i===e&&1===t&&2===n&&r!==e}catch(t){return!1}}(),d="".split,g=Math.max,m=l.bind,v=l.call,S=h?m.call(v,d):function(t,n){return d.call(t,n)},j=function(t){return a()(t)?S(t,""):t},w=function(t,n){var r=arguments.length>2?arguments[2]:[];if("string"!=typeof t&&l(t))return r;for(var e=s?t:j(t),o=e.length,u=g(0,n)||0;u<o;u+=1)r[r.length]=t[u];return r};function O(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var r=[],e=!0,o=!1,u=void 0;try{for(var i,f=t[Symbol.iterator]();!(e=(i=f.next()).done)&&(r.push(i.value),!n||r.length!==n);e=!0);}catch(t){o=!0,u=t}finally{try{e||null==f.return||f.return()}finally{if(o)throw u}}return r}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var $=w.bind,x=w.call,T={},P=T.constructor,_=T.toString,E=function(t,n){return t>=n?t:n},F=function(t){if("function"!=typeof t&&"[object Function]"!==_.apply(t))throw new TypeError("bind called on incompatible "+t)},M=[function(t){return function(){return t.apply(this,w(arguments))}},function(t,n){return function(r){return t.apply(this,w(arguments,n,[r]))}},function(t,n){return function(r,e){return t.apply(this,w(arguments,n,[r,e]))}},function(t,n){return function(r,e,o){return t.apply(this,w(arguments,n,[r,e,o]))}},function(t,n){return function(r,e,o,u){return t.apply(this,w(arguments,n,[r,e,o,u]))}},function(t,n){return function(r,e,o,u,i){return t.apply(this,w(arguments,n,[r,e,o,u,i]))}},function(t,n){return function(r,e,o,u,i,f){return t.apply(this,w(arguments,n,[r,e,o,u,i,f]))}},function(t,n){return function(r,e,o,u,i,f,c){return t.apply(this,w(arguments,n,[r,e,o,u,i,f,c]))}},function(t,n){return function(r,e,o,u,i,f,c,l){return t.apply(this,w(arguments,n,[r,e,o,u,i,f,c,l]))}}],D=function(t){var n=O(t,3),r=n[0],e=n[1],o=n[2],u=E(0,e.length-E(0,o.length-2)),i=M[u],f=i?i(r,u):M[0](r);if(e.prototype){var c=function(){};c.prototype=e.prototype,f.prototype=new c,c.prototype=null}return f},A=function(t,n){var r=t.apply(this,n);return P(r)===r?r:this},k=h?x.bind($):function(t,n){F(t);var r,e=arguments,o=function(){var o=w(arguments,0,w(e,2));return this instanceof r?A.apply(this,[t,o]):t.apply(n,o)};return r=D([o,t,e])},I=TypeError,N=k.apply,X=k(k.call,N),z=k(N,{}.toString),C=function(t){if("function"!=typeof t&&"[object Function]"!==z(t))throw new I(t+" is not a function");return t},G=function(t,n){return X(C(t),n,w(arguments[2]))},q={}.toString,B=function(t){return function(t){if("function"!=typeof t&&"[object Function]"!==G(q,t))throw new TypeError("methodize called on incompatible "+t)}(t),function(){return G(t,arguments[0],w(arguments,1))}},H=(0).constructor,J=B("".charAt),K=B("".slice),L=B("".search),Q=B("".replace),R=B("".indexOf),U=B([].join),V=/^-?(?:(?:\d|[1-9]\d*)(?:\.\d+)?)(?:e[+-]?\d+)?$/i,W=B(V.test);n.default=function(t){var n,r=t;if(0===r&&1/r<0)r="-0";else if(r=f(r),!1===W(V,r))throw new TypeError("not a valid base 10 numeric value");"-"===J(r,0)?(r=K(r,1),n=-1):n=1;var e=R(r,".");e>-1&&(r=Q(r,".",""));var o=e,u=L(r,/e/i);u>0?(o<0&&(o=u),o+=H(K(r,u+1)),r=K(r,0,u)):o<0&&(o=r.length);var i,c,l=r.length;for(u=0;u<l&&"0"===J(r,u);)u+=1;if(u===l)c=0,i=[0];else{if(l>0)do{l-=1}while("0"===J(r,l)&&l>0);c=o-u-1,(i=[]).length=l+1;for(var p=0;u<=l;)i[p]=H(J(r,u)),p+=1,u+=1}var a=U(i,""),y=a.length;if(c<0){for(c+=1;c;)a="0"+a,c+=1;a="0."+a}else if(c>0)if((c+=1)>y)for(c-=y;c;)a+="0",c-=1;else c<y&&(a=K(a,0,c)+"."+K(a,c));else y>1&&(a=J(a,0)+"."+K(a,1));return n<0?"-"+a:a}}])});
//# sourceMappingURL=number-to-decimal-form-string-x.min.js.map