@bloks/numbers
Advanced tools
Comparing version 25.0.59 to 26.0.0
@@ -28,2 +28,5 @@ 'use strict'; | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
@@ -50,24 +53,20 @@ } | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it; | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (it) return (it = it.call(o)).next.bind(it); | ||
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}; | ||
} | ||
it = o[Symbol.iterator](); | ||
return it.next.bind(it); | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
@@ -74,0 +73,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("bignumber.js"),n=t(require("@jafri/numbro")),o=t(require("dayjs")),e=t(require("dayjs/plugin/relativeTime")),i=t(require("dayjs/plugin/utc")),s=t(require("dayjs/plugin/timezone")),u=t(require("dayjs/plugin/advancedFormat"));function a(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=t[n];return o}function m(t,r){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return a(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,void 0):void 0}}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}var c,p,f=function(t,r){if(!t)throw new Error(r)};(c=(p=exports.Maths||(exports.Maths={})).Operations||(p.Operations={})).PLUS="plus",c.MULTIPLY="multipliedBy",c.DIVIDE="dividedBy",c.MINUS="minus";var d=function(){function t(t){this.symbol=new y({code:t.code,precision:t.precision}),this.amount=new r.BigNumber(t.amount)}t.fromString=function(n){var o=n.split(" "),e=o[0];return new t({code:o[1],precision:(e.split(".")[1]||[]).length,amount:new r.BigNumber(e)})},t.fromSymbol=function(r){var n=r.symbol,o=r.amount;if(!(n instanceof y))throw new Error("Invalid symbol");return new t({code:n.code,precision:n.precision,amount:o})};var n,o=t.prototype;return o.isEqualTo=function(t){return this.isLooselyEqualTo(t)&&this.amount==t.amount},o.isLooselyEqualTo=function(t){return this.symbol.isEqualTo(t.symbol)},o.toString=function(){return new r.BigNumber(this.amount).toFixed(this.symbol.precision,r.BigNumber.ROUND_DOWN)+" "+this.symbol.code},o.modifyAmount=function(n,o){var e=new r.BigNumber(0);return("number"==typeof n||r.BigNumber.isBigNumber(n))&&(e=new r.BigNumber(n)),n instanceof t&&(f(this.isLooselyEqualTo(n),"invalid symbol"),e=new r.BigNumber(n.amount)),t.fromSymbol({symbol:this.symbol,amount:this.amount[o](e)})},o.plus=function(t){return this.modifyAmount(t,exports.Maths.Operations.PLUS)},o.minus=function(t){return this.modifyAmount(t,exports.Maths.Operations.MINUS)},o.multipliedBy=function(t){return this.modifyAmount(t,exports.Maths.Operations.MULTIPLY)},o.dividedBy=function(t){return this.modifyAmount(t,exports.Maths.Operations.DIVIDE)},(n=[{key:"integerAmount",get:function(){var t=Math.pow(10,this.symbol.precision);return this.amount.multipliedBy(t)}}])&&function(t,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}(t.prototype,n),t}(),l=function(){function t(t){if(!(t.quantity instanceof d))throw new Error("Invalid quantity");this.quantity=t.quantity,this.contract=t.contract}t.fromRaw=function(r){var n=r.contract;return new t({quantity:d.fromString(r.quantity),contract:n})},t.fromExtendedSymbol=function(r,n){if(!(r instanceof b))throw new Error("Invalid extended symbol");return new t({quantity:d.fromSymbol({symbol:r.sym,amount:n}),contract:r.contract})};var n=t.prototype;return n.isEqualTo=function(t){return this.contract===t.contract&&this.quantity.isEqualTo(t.quantity)},n.isLooselyEqualTo=function(t){return this.contract===t.contract&&this.quantity.isLooselyEqualTo(t.quantity)},n.toString=function(){return this.quantity.toString()+"@"+this.contract},n.toExtendedSymbol=function(){return new b(this.quantity.symbol,this.contract)},n.modifyAmount=function(n,o){var e=new r.BigNumber(0);return n instanceof t?(f(this.isLooselyEqualTo(n),"invalid contract or symbol"),e=n.quantity):e=n,new t({contract:this.contract,quantity:this.quantity.modifyAmount(e,o)})},n.plus=function(t){return this.modifyAmount(t,exports.Maths.Operations.PLUS)},n.minus=function(t){return this.modifyAmount(t,exports.Maths.Operations.MINUS)},n.multipliedBy=function(t){return this.modifyAmount(t,exports.Maths.Operations.MULTIPLY)},n.dividedBy=function(t){return this.modifyAmount(t,exports.Maths.Operations.DIVIDE)},t}(),y=function(){function t(t){this.precision=t.precision,this.code=t.code}t.fromString=function(r){var n=r.split(",");return new t({precision:+n[0],code:n[1]})};var r=t.prototype;return r.isEqualTo=function(t){return this.code===t.code&&this.precision===t.precision},r.toString=function(){return this.precision+","+this.code},t}(),b=function(){function t(t,r){this.sym=t,this.contract=r}t.fromRaw=function(r){var n=r.contract;return new t(y.fromString(r.sym),n)};var r=t.prototype;return r.isEqualTo=function(t){return this.sym.isEqualTo(t.sym)&&this.contract===t.contract},r.toString=function(){return this.sym.toString()+"@"+this.contract},t}(),h={GBP:{symbol:"£",precision:2},EUR:{symbol:"€",precision:2},JPY:{symbol:"¥",precision:0},CAD:{symbol:"CA$",precision:2},USD:{symbol:"$",precision:2},INR:{symbol:"₹",precision:2},CNY:{symbol:"CN¥",precision:2},HKD:{symbol:"HK$",precision:2},KRW:{symbol:"₩",precision:0},AUD:{symbol:"AUD$",precision:2},SAR:{symbol:"SR",precision:2},ETH:{symbol:"Ξ",precision:4},BTC:{symbol:"₿",precision:8},EOS:{symbol:"EOS",precision:4}},x={decimalSeparator:".",groupSeparator:",",groupSize:3};function v(t,n,o){return void 0===o&&(o=r.BigNumber.ROUND_DOWN),new r.BigNumber(t).toFixed(n,o)}function g(t,n,o){return void 0===o&&(o=r.BigNumber.ROUND_DOWN),new r.BigNumber(t).toFormat(n,o,x)}function w(t){var r=t.split(" "),n=r[0],o=r[1],e=(n.split(".")[1]||[]).length;return{amount:+n,symbol:{code:o,precision:e}}}function M(t,r){return void 0===r&&(r=!1),n(t).format({thousandSeparated:!0,trimMantissa:r})}function N(t,r,o){return void 0===o&&(o=!1),n(t).format({thousandSeparated:!0,mantissa:r,trimMantissa:o})}function S(t,r,o,e){return void 0===e&&(e=!1),n(t).format({thousandSeparated:!0,mantissa:o,trimMantissa:e})+" "+r}function D(t){return o(t)}function A(t){return o(t).utc()}function B(t,r){return void 0===r&&(r="MMM-DD-YYYY, hh:mm:ss A"),o(t).format(r)}function T(t){return new Date(t)}function q(t){return t="Z"===t.slice(-1)?t:t+"Z",new Date(t)}function E(t,r){return void 0===r&&(r=3),o(t).clone().subtract(r,"days")}function Y(t,r){return void 0===r&&(r=3),o(t).clone().add(r,"days")}r.BigNumber.set({ROUNDING_MODE:1}),o.extend(e),o.extend(i),o.extend(s),o.extend(u),exports.Asset=d,exports.ExtendedAsset=l,exports.ExtendedSymbol=b,exports.Symbol=y,exports.add=function(){for(var t=new r.BigNumber(0),n=arguments.length,o=new Array(n),e=0;e<n;e++)o[e]=arguments[e];if(o.length)for(var i,s=m(o);!(i=s()).done;){var u=i.value;t=t.plus(u)}return t},exports.bytesToKB=function(t){return void 0===t&&(t=0),n(t/1024).format({thousandSeparated:!1,mantissa:2})},exports.calculatePercentage=function(t,n,o){return v(new r.BigNumber(t).multipliedBy(n),o,r.BigNumber.ROUND_DOWN)},exports.currencyToSymbol=function(t){return h[t]},exports.dateToUtcTimePoint=function(t){return void 0===t&&(t=D()),o(t).utc().format("YYYY-MM-DDTHH:mm:ss.SSS")},exports.displayAsset=function(t){var r=w(t),n=r.symbol.code;return M(r.amount)+" "+n},exports.displayNumber=M,exports.displayNumberAsAmount=N,exports.displayNumberAsAsset=S,exports.displayNumberAsCurrency=function(t){var r=t.number,o=t.precision,e=t.average,i=void 0!==e&&e,s=t.lowPrecision,u=void 0===s||s,a=t.trimMantissa,m=void 0!==a&&a,c=t.currency,p=void 0===c?"USD":c;if(!h[p])throw new Error("Unsupported currency");var f=h[p],d=f.symbol,l={thousandSeparated:!0,mantissa:void 0!==o?o:f.precision,trimMantissa:m,average:i};return i&&(l.lowPrecision=u),""+d+n(r).format(l)},exports.displayRawNumberAsAsset=function(t,r,n,o){return void 0===o&&(o=!1),S(t/Math.pow(10,n),r,n,o)},exports.divide=function(t,n){return new r.BigNumber(t).dividedBy(n)},exports.emptyTimePoint="1970-01-01T00:00:00.000",exports.endDate=Y,exports.eosDisplayFormatting=function(t,r,n){return g(t,n)+" "+r},exports.formatDate=B,exports.formatDateLocal=function(t,r){return void 0===r&&(r="MMM-DD-YYYY, hh:mm:ss A"),o(t).utc().format(r)},exports.formatEndDate=function(t){return Y(t).format("MMM-DD-YYYY, hh:mm:ss A")},exports.formatStartDate=function(t){return E(t).format("MMM-DD-YYYY, hh:mm:ss A")},exports.inFuture=function(t,r){return void 0===r&&(r=!1),r?A(t).isAfter(A()):D(t).isAfter(D())},exports.inPast=function(t,r){return void 0===r&&(r=!1),r?A(t).isBefore(A()):D(t).isBefore(D())},exports.isSameDay=function(t,r){return void 0===r&&(r=D()),o(t).isSame(o(r),"day")},exports.millisecondsFrom=function(t,r){return void 0===r&&(r=D()),o(t).diff(o(r))},exports.multiply=function(t,n){return new r.BigNumber(t).multipliedBy(n)},exports.numberToAmount=v,exports.numberToAmountFormatted=g,exports.numberToAsset=function(t,r,o,e){return void 0===e&&(e=!1),n(t).format({thousandSeparated:!1,mantissa:o,trimMantissa:e})+" "+r},exports.numberToEos=function(t,r,n){return v(t,n)+" "+r},exports.numberToEosRoundUp=function(t,n,o){return v(t,o,r.BigNumber.ROUND_UP)+" "+n},exports.parseCpu=function(t){var r=0,n="";return t<1e3?(r=t,n="µs"):t<1e6?(r=t/1e3,n="ms"):t<6e7?(r=t/1e6,n="s"):t<36e8?(r=t/6e7,n="min"):t<36e11?(r=t/36e8,n="hours"):(r=t/864e8,n="days"),N(r,2,!0)+" "+n},exports.parseNetAndRam=function(t){var r=0,n="";return t<1024?(r=t,n="Bytes"):t<1048576?(r=t/1024,n="KB"):t<1073741824?(r=t/1048576,n="MB"):t<1099511627776?(r=t/1073741824,n="GB"):t<0x4000000000000&&(r=t/1099511627776,n="TB"),N(r,2,!0)+" "+n},exports.parseRex=function(t){return new r.BigNumber(t).dividedBy(1e4)},exports.parseSeconds=function(t){var r=0,n=0,o=0,e="";return t>86400&&(t-=86400*(r+=Math.floor(t/86400)),e+=r.toFixed(0)+" "+(1===r?"Day":"Days")+" "),t>3600&&(t-=3600*(n+=Math.floor(t/3600)),e+=n.toFixed(0)+" "+(1===n?"Hour":"Hours")+" "),t>60&&(t-=60*(o+=Math.floor(t/60)),e+=o.toFixed(0)+" "+(1===o?"Minute":"Minutes")+" "),t>0&&(e+=t.toFixed(0)+" Seconds "),e},exports.parseTimestamp=function(t,r){return void 0===r&&(r="MMM-DD-YYYY, hh:mm:ss A"),B(T(t),r)},exports.parseUtcTimestamp=function(t,r){return void 0===r&&(r="MMM-DD-YYYY, hh:mm:ss A"),B(q(t),r)},exports.secondsFrom=function(t,r){return void 0===r&&(r=D()),o(t).diff(o(r),"second")},exports.split=w,exports.startDate=E,exports.substract=function(t,n){return new r.BigNumber(t).minus(n)},exports.time=D,exports.timestampFromNow=function(t){return D(t).fromNow()},exports.timestampToDate=T,exports.toBN=function(t){return new r.BigNumber(t)},exports.toNumbro=function(t){return n(t)},exports.unixTime=function(t){return o.unix(t)},exports.utcTime=A,exports.utcTimeToLocal=function(t){return o(t).local()},exports.utcTimestampFromNow=function(t){return D(t="Z"===t.slice(-1)?t:t+"Z").fromNow()},exports.utcTimestampToDate=q; | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("bignumber.js"),n=t(require("@jafri/numbro")),o=t(require("dayjs")),e=t(require("dayjs/plugin/relativeTime")),i=t(require("dayjs/plugin/utc")),s=t(require("dayjs/plugin/timezone")),u=t(require("dayjs/plugin/advancedFormat"));function a(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,o=new Array(r);n<r;n++)o[n]=t[n];return o}function m(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return a(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,void 0):void 0}}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,p,f=function(t,r){if(!t)throw new Error(r)};(c=(p=exports.Maths||(exports.Maths={})).Operations||(p.Operations={})).PLUS="plus",c.MULTIPLY="multipliedBy",c.DIVIDE="dividedBy",c.MINUS="minus";var d=function(){function t(t){this.symbol=new y({code:t.code,precision:t.precision}),this.amount=new r.BigNumber(t.amount)}t.fromString=function(n){var o=n.split(" "),e=o[0];return new t({code:o[1],precision:(e.split(".")[1]||[]).length,amount:new r.BigNumber(e)})},t.fromSymbol=function(r){var n=r.symbol,o=r.amount;if(!(n instanceof y))throw new Error("Invalid symbol");return new t({code:n.code,precision:n.precision,amount:o})};var n,o,e=t.prototype;return e.isEqualTo=function(t){return this.isLooselyEqualTo(t)&&this.amount==t.amount},e.isLooselyEqualTo=function(t){return this.symbol.isEqualTo(t.symbol)},e.toString=function(){return new r.BigNumber(this.amount).toFixed(this.symbol.precision,r.BigNumber.ROUND_DOWN)+" "+this.symbol.code},e.modifyAmount=function(n,o){var e=new r.BigNumber(0);return("number"==typeof n||r.BigNumber.isBigNumber(n))&&(e=new r.BigNumber(n)),n instanceof t&&(f(this.isLooselyEqualTo(n),"invalid symbol"),e=new r.BigNumber(n.amount)),t.fromSymbol({symbol:this.symbol,amount:this.amount[o](e)})},e.plus=function(t){return this.modifyAmount(t,exports.Maths.Operations.PLUS)},e.minus=function(t){return this.modifyAmount(t,exports.Maths.Operations.MINUS)},e.multipliedBy=function(t){return this.modifyAmount(t,exports.Maths.Operations.MULTIPLY)},e.dividedBy=function(t){return this.modifyAmount(t,exports.Maths.Operations.DIVIDE)},n=t,(o=[{key:"integerAmount",get:function(){var t=Math.pow(10,this.symbol.precision);return this.amount.multipliedBy(t)}}])&&function(t,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),t}(),l=function(){function t(t){if(!(t.quantity instanceof d))throw new Error("Invalid quantity");this.quantity=t.quantity,this.contract=t.contract}t.fromRaw=function(r){var n=r.contract;return new t({quantity:d.fromString(r.quantity),contract:n})},t.fromExtendedSymbol=function(r,n){if(!(r instanceof b))throw new Error("Invalid extended symbol");return new t({quantity:d.fromSymbol({symbol:r.sym,amount:n}),contract:r.contract})};var n=t.prototype;return n.isEqualTo=function(t){return this.contract===t.contract&&this.quantity.isEqualTo(t.quantity)},n.isLooselyEqualTo=function(t){return this.contract===t.contract&&this.quantity.isLooselyEqualTo(t.quantity)},n.toString=function(){return this.quantity.toString()+"@"+this.contract},n.toExtendedSymbol=function(){return new b(this.quantity.symbol,this.contract)},n.modifyAmount=function(n,o){var e=new r.BigNumber(0);return n instanceof t?(f(this.isLooselyEqualTo(n),"invalid contract or symbol"),e=n.quantity):e=n,new t({contract:this.contract,quantity:this.quantity.modifyAmount(e,o)})},n.plus=function(t){return this.modifyAmount(t,exports.Maths.Operations.PLUS)},n.minus=function(t){return this.modifyAmount(t,exports.Maths.Operations.MINUS)},n.multipliedBy=function(t){return this.modifyAmount(t,exports.Maths.Operations.MULTIPLY)},n.dividedBy=function(t){return this.modifyAmount(t,exports.Maths.Operations.DIVIDE)},t}(),y=function(){function t(t){this.precision=t.precision,this.code=t.code}t.fromString=function(r){var n=r.split(",");return new t({precision:+n[0],code:n[1]})};var r=t.prototype;return r.isEqualTo=function(t){return this.code===t.code&&this.precision===t.precision},r.toString=function(){return this.precision+","+this.code},t}(),b=function(){function t(t,r){this.sym=t,this.contract=r}t.fromRaw=function(r){var n=r.contract;return new t(y.fromString(r.sym),n)};var r=t.prototype;return r.isEqualTo=function(t){return this.sym.isEqualTo(t.sym)&&this.contract===t.contract},r.toString=function(){return this.sym.toString()+"@"+this.contract},t}(),h={GBP:{symbol:"£",precision:2},EUR:{symbol:"€",precision:2},JPY:{symbol:"¥",precision:0},CAD:{symbol:"CA$",precision:2},USD:{symbol:"$",precision:2},INR:{symbol:"₹",precision:2},CNY:{symbol:"CN¥",precision:2},HKD:{symbol:"HK$",precision:2},KRW:{symbol:"₩",precision:0},AUD:{symbol:"AUD$",precision:2},SAR:{symbol:"SR",precision:2},ETH:{symbol:"Ξ",precision:4},BTC:{symbol:"₿",precision:8},EOS:{symbol:"EOS",precision:4}},x={decimalSeparator:".",groupSeparator:",",groupSize:3};function v(t,n,o){return void 0===o&&(o=r.BigNumber.ROUND_DOWN),new r.BigNumber(t).toFixed(n,o)}function g(t,n,o){return void 0===o&&(o=r.BigNumber.ROUND_DOWN),new r.BigNumber(t).toFormat(n,o,x)}function w(t){var r=t.split(" "),n=r[0],o=r[1],e=(n.split(".")[1]||[]).length;return{amount:+n,symbol:{code:o,precision:e}}}function M(t,r){return void 0===r&&(r=!1),n(t).format({thousandSeparated:!0,trimMantissa:r})}function N(t,r,o){return void 0===o&&(o=!1),n(t).format({thousandSeparated:!0,mantissa:r,trimMantissa:o})}function S(t,r,o,e){return void 0===e&&(e=!1),n(t).format({thousandSeparated:!0,mantissa:o,trimMantissa:e})+" "+r}function D(t){return o(t)}function A(t){return o(t).utc()}function B(t,r){return void 0===r&&(r="MMM-DD-YYYY, hh:mm:ss A"),o(t).format(r)}function T(t){return new Date(t)}function q(t){return t="Z"===t.slice(-1)?t:t+"Z",new Date(t)}function E(t,r){return void 0===r&&(r=3),o(t).clone().subtract(r,"days")}function Y(t,r){return void 0===r&&(r=3),o(t).clone().add(r,"days")}r.BigNumber.set({ROUNDING_MODE:1}),o.extend(e),o.extend(i),o.extend(s),o.extend(u),exports.Asset=d,exports.ExtendedAsset=l,exports.ExtendedSymbol=b,exports.Symbol=y,exports.add=function(){for(var t=new r.BigNumber(0),n=arguments.length,o=new Array(n),e=0;e<n;e++)o[e]=arguments[e];if(o.length)for(var i,s=m(o);!(i=s()).done;){var u=i.value;t=t.plus(u)}return t},exports.bytesToKB=function(t){return void 0===t&&(t=0),n(t/1024).format({thousandSeparated:!1,mantissa:2})},exports.calculatePercentage=function(t,n,o){return v(new r.BigNumber(t).multipliedBy(n),o,r.BigNumber.ROUND_DOWN)},exports.currencyToSymbol=function(t){return h[t]},exports.dateToUtcTimePoint=function(t){return void 0===t&&(t=D()),o(t).utc().format("YYYY-MM-DDTHH:mm:ss.SSS")},exports.displayAsset=function(t){var r=w(t),n=r.symbol.code;return M(r.amount)+" "+n},exports.displayNumber=M,exports.displayNumberAsAmount=N,exports.displayNumberAsAsset=S,exports.displayNumberAsCurrency=function(t){var r=t.number,o=t.precision,e=t.average,i=void 0!==e&&e,s=t.lowPrecision,u=void 0===s||s,a=t.trimMantissa,m=void 0!==a&&a,c=t.currency,p=void 0===c?"USD":c;if(!h[p])throw new Error("Unsupported currency");var f=h[p],d=f.symbol,l={thousandSeparated:!0,mantissa:void 0!==o?o:f.precision,trimMantissa:m,average:i};return i&&(l.lowPrecision=u),""+d+n(r).format(l)},exports.displayRawNumberAsAsset=function(t,r,n,o){return void 0===o&&(o=!1),S(t/Math.pow(10,n),r,n,o)},exports.divide=function(t,n){return new r.BigNumber(t).dividedBy(n)},exports.emptyTimePoint="1970-01-01T00:00:00.000",exports.endDate=Y,exports.eosDisplayFormatting=function(t,r,n){return g(t,n)+" "+r},exports.formatDate=B,exports.formatDateLocal=function(t,r){return void 0===r&&(r="MMM-DD-YYYY, hh:mm:ss A"),o(t).utc().format(r)},exports.formatEndDate=function(t){return Y(t).format("MMM-DD-YYYY, hh:mm:ss A")},exports.formatStartDate=function(t){return E(t).format("MMM-DD-YYYY, hh:mm:ss A")},exports.inFuture=function(t,r){return void 0===r&&(r=!1),r?A(t).isAfter(A()):D(t).isAfter(D())},exports.inPast=function(t,r){return void 0===r&&(r=!1),r?A(t).isBefore(A()):D(t).isBefore(D())},exports.isSameDay=function(t,r){return void 0===r&&(r=D()),o(t).isSame(o(r),"day")},exports.millisecondsFrom=function(t,r){return void 0===r&&(r=D()),o(t).diff(o(r))},exports.multiply=function(t,n){return new r.BigNumber(t).multipliedBy(n)},exports.numberToAmount=v,exports.numberToAmountFormatted=g,exports.numberToAsset=function(t,r,o,e){return void 0===e&&(e=!1),n(t).format({thousandSeparated:!1,mantissa:o,trimMantissa:e})+" "+r},exports.numberToEos=function(t,r,n){return v(t,n)+" "+r},exports.numberToEosRoundUp=function(t,n,o){return v(t,o,r.BigNumber.ROUND_UP)+" "+n},exports.parseCpu=function(t){var r=0,n="";return t<1e3?(r=t,n="µs"):t<1e6?(r=t/1e3,n="ms"):t<6e7?(r=t/1e6,n="s"):t<36e8?(r=t/6e7,n="min"):t<36e11?(r=t/36e8,n="hours"):(r=t/864e8,n="days"),N(r,2,!0)+" "+n},exports.parseNetAndRam=function(t){var r=0,n="";return t<1024?(r=t,n="Bytes"):t<1048576?(r=t/1024,n="KB"):t<1073741824?(r=t/1048576,n="MB"):t<1099511627776?(r=t/1073741824,n="GB"):t<0x4000000000000&&(r=t/1099511627776,n="TB"),N(r,2,!0)+" "+n},exports.parseRex=function(t){return new r.BigNumber(t).dividedBy(1e4)},exports.parseSeconds=function(t){var r=0,n=0,o=0,e="";return t>86400&&(t-=86400*(r+=Math.floor(t/86400)),e+=r.toFixed(0)+" "+(1===r?"Day":"Days")+" "),t>3600&&(t-=3600*(n+=Math.floor(t/3600)),e+=n.toFixed(0)+" "+(1===n?"Hour":"Hours")+" "),t>60&&(t-=60*(o+=Math.floor(t/60)),e+=o.toFixed(0)+" "+(1===o?"Minute":"Minutes")+" "),t>0&&(e+=t.toFixed(0)+" Seconds "),e},exports.parseTimestamp=function(t,r){return void 0===r&&(r="MMM-DD-YYYY, hh:mm:ss A"),B(T(t),r)},exports.parseUtcTimestamp=function(t,r){return void 0===r&&(r="MMM-DD-YYYY, hh:mm:ss A"),B(q(t),r)},exports.secondsFrom=function(t,r){return void 0===r&&(r=D()),o(t).diff(o(r),"second")},exports.split=w,exports.startDate=E,exports.substract=function(t,n){return new r.BigNumber(t).minus(n)},exports.time=D,exports.timestampFromNow=function(t){return D(t).fromNow()},exports.timestampToDate=T,exports.toBN=function(t){return new r.BigNumber(t)},exports.toNumbro=function(t){return n(t)},exports.unixTime=function(t){return o.unix(t)},exports.utcTime=A,exports.utcTimeToLocal=function(t){return o(t).local()},exports.utcTimestampFromNow=function(t){return D(t="Z"===t.slice(-1)?t:t+"Z").fromNow()},exports.utcTimestampToDate=q; | ||
//# sourceMappingURL=numbers.cjs.production.min.js.map |
@@ -22,2 +22,5 @@ import { BigNumber } from 'bignumber.js'; | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
@@ -44,24 +47,20 @@ } | ||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { | ||
var it; | ||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; | ||
if (it) return (it = it.call(o)).next.bind(it); | ||
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { | ||
if (it) o = it; | ||
var i = 0; | ||
return function () { | ||
if (i >= o.length) return { | ||
done: true | ||
}; | ||
} | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
return { | ||
done: false, | ||
value: o[i++] | ||
}; | ||
}; | ||
} | ||
it = o[Symbol.iterator](); | ||
return it.next.bind(it); | ||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
@@ -68,0 +67,0 @@ |
{ | ||
"name": "@bloks/numbers", | ||
"version": "25.0.59", | ||
"version": "26.0.0", | ||
"author": "jafri", | ||
@@ -23,3 +23,3 @@ "module": "dist/api.esm.js", | ||
}, | ||
"gitHead": "1cfd5cdd0b59ec1f46ccbcb72eb0e8d0ce796965" | ||
"gitHead": "6695f2664c4cb1ba05b03bdca62eecdc286a1435" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
172323
1755