@bloks/numbers
Advanced tools
Comparing version 25.0.58 to 25.0.59
@@ -44,6 +44,7 @@ import { BigNumber as BN } from 'bignumber.js'; | ||
}); | ||
static fromExtendedSymbol({ symbol, amount }: { | ||
symbol: ExtendedSymbol; | ||
amount: BN.Instance; | ||
static fromRaw({ quantity, contract }: { | ||
quantity: string; | ||
contract: string; | ||
}): ExtendedAsset; | ||
static fromExtendedSymbol(symbol: ExtendedSymbol, amount: BN.Instance): ExtendedAsset; | ||
isEqualTo(extendedAsset: ExtendedAsset): boolean; | ||
@@ -78,4 +79,8 @@ isLooselyEqualTo(extendedAsset: ExtendedAsset): boolean; | ||
constructor(sym: Symbol, contract: string); | ||
static fromRaw({ sym, contract }: { | ||
sym: string; | ||
contract: string; | ||
}): ExtendedSymbol; | ||
isEqualTo(extendedSymbol: ExtendedSymbol): boolean; | ||
toString(): string; | ||
} |
@@ -197,6 +197,12 @@ 'use strict'; | ||
ExtendedAsset.fromExtendedSymbol = function fromExtendedSymbol(_ref2) { | ||
var symbol = _ref2.symbol, | ||
amount = _ref2.amount; | ||
ExtendedAsset.fromRaw = function fromRaw(_ref2) { | ||
var quantity = _ref2.quantity, | ||
contract = _ref2.contract; | ||
return new ExtendedAsset({ | ||
quantity: Asset.fromString(quantity), | ||
contract: contract | ||
}); | ||
}; | ||
ExtendedAsset.fromExtendedSymbol = function fromExtendedSymbol(symbol, amount) { | ||
if (!(symbol instanceof ExtendedSymbol)) { | ||
@@ -302,2 +308,8 @@ throw new Error('Invalid extended symbol'); | ||
ExtendedSymbol.fromRaw = function fromRaw(_ref3) { | ||
var sym = _ref3.sym, | ||
contract = _ref3.contract; | ||
return new ExtendedSymbol(Symbol$1.fromString(sym), contract); | ||
}; | ||
var _proto4 = ExtendedSymbol.prototype; | ||
@@ -304,0 +316,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.fromExtendedSymbol=function(r){var n=r.symbol,o=r.amount;if(!(n instanceof b))throw new Error("Invalid extended symbol");return new t({quantity:d.fromSymbol({symbol:n.sym,amount:o}),contract:n.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}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 M(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 N(t,r){return void 0===r&&(r=!1),n(t).format({thousandSeparated:!0,trimMantissa:r})}function D(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 w(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=w()),o(t).utc().format("YYYY-MM-DDTHH:mm:ss.SSS")},exports.displayAsset=function(t){var r=M(t),n=r.symbol.code;return N(r.amount)+" "+n},exports.displayNumber=N,exports.displayNumberAsAmount=D,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()):w(t).isAfter(w())},exports.inPast=function(t,r){return void 0===r&&(r=!1),r?A(t).isBefore(A()):w(t).isBefore(w())},exports.isSameDay=function(t,r){return void 0===r&&(r=w()),o(t).isSame(o(r),"day")},exports.millisecondsFrom=function(t,r){return void 0===r&&(r=w()),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"),D(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"),D(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=w()),o(t).diff(o(r),"second")},exports.split=M,exports.startDate=E,exports.substract=function(t,n){return new r.BigNumber(t).minus(n)},exports.time=w,exports.timestampFromNow=function(t){return w(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 w(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;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; | ||
//# sourceMappingURL=numbers.cjs.production.min.js.map |
@@ -193,6 +193,12 @@ import { BigNumber } from 'bignumber.js'; | ||
ExtendedAsset.fromExtendedSymbol = function fromExtendedSymbol(_ref2) { | ||
var symbol = _ref2.symbol, | ||
amount = _ref2.amount; | ||
ExtendedAsset.fromRaw = function fromRaw(_ref2) { | ||
var quantity = _ref2.quantity, | ||
contract = _ref2.contract; | ||
return new ExtendedAsset({ | ||
quantity: Asset.fromString(quantity), | ||
contract: contract | ||
}); | ||
}; | ||
ExtendedAsset.fromExtendedSymbol = function fromExtendedSymbol(symbol, amount) { | ||
if (!(symbol instanceof ExtendedSymbol)) { | ||
@@ -298,2 +304,8 @@ throw new Error('Invalid extended symbol'); | ||
ExtendedSymbol.fromRaw = function fromRaw(_ref3) { | ||
var sym = _ref3.sym, | ||
contract = _ref3.contract; | ||
return new ExtendedSymbol(Symbol$1.fromString(sym), contract); | ||
}; | ||
var _proto4 = ExtendedSymbol.prototype; | ||
@@ -300,0 +312,0 @@ |
{ | ||
"name": "@bloks/numbers", | ||
"version": "25.0.58", | ||
"version": "25.0.59", | ||
"author": "jafri", | ||
@@ -23,3 +23,3 @@ "module": "dist/api.esm.js", | ||
}, | ||
"gitHead": "c7feb23e14c92f2cd3a204ec57fee484d150f162" | ||
"gitHead": "1cfd5cdd0b59ec1f46ccbcb72eb0e8d0ce796965" | ||
} |
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
171807
1754