Socket
Socket
Sign inDemoInstall

crypto-convert

Package Overview
Dependencies
27
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.5 to 2.1.0

cdn/crypto-convert.min.js.LICENSE.txt

3

cdn/crypto-convert.min.js

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

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("FormData"),require("fetch")):"function"==typeof define&&define.amd?define(["FormData","fetch"],e):"object"==typeof exports?exports.convert=e(require("FormData"),require("fetch")):t.convert=e(t.FormData,t.fetch)}(this,((__WEBPACK_EXTERNAL_MODULE__88__,__WEBPACK_EXTERNAL_MODULE__265__)=>(()=>{"use strict";var __webpack_modules__={945:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))};function n(t,e){const o="undefined"!=typeof window?null===window||void 0===window?void 0:window.fetch:r(265),a="undefined"!=typeof window?null===window||void 0===window?void 0:window.FormData:r(88);if(!o)throw new Error("Fetch API is not installed. If you are using Node please run `npm install node-fetch`");if(!a)throw new Error("FormData is not installed. If you are using Node please run `npm install form-data`");const s=t=>Object.assign(Object.assign({},t),{headers:Object.assign({},t.headers),params:Object.assign({},t.params),values:Object.assign({},t.values)}),l=t=>{var e,r;if("Object"!=(null===(r=null===(e=null==t?void 0:t.__proto__)||void 0===e?void 0:e.constructor)||void 0===r?void 0:r.name))throw new Error("Invalid $options object.");let i=s(t.$options||{});return delete t.$options,Object.assign(Object.assign({},i),{values:Object.assign(Object.assign({},i.values),t)})},c=(t,e,r=!1)=>{let i=r?t||{}:s(t||{}),n=s(e||{});return n.headers=Object.assign(Object.assign({},i.headers),n.headers),n.params=Object.assign(Object.assign({},i.params),n.params),n.values=Object.assign(Object.assign({},i.values),n.values),Object.assign(i,n),i};t=Object.assign({},t);let u={base:"",headers:{"User-Agent":"Rests JS (v1.1.0)"},params:{},values:{},on_error:void 0,on_success:void 0,on_request:void 0,fetch_agent:null};c(u,(null==t?void 0:t.$options)||{},!0),c(u,e,!0);const d={json:"application/json",form:"multipart/form-data",urlencoded:"application/x-www-form-urlencoded",text:"text/plain"},p=Object.values(d),y=["headers","body","query","path"],f={POST:"body",GET:"query"},m={"multipart/form-data":function(){var t=new a;return t.toString=function(){return this},t},"application/x-www-form-urlencoded":function(){return new URLSearchParams},"application/json":function(){return{append:function(t,e){this.data=this.data||{},this.data[t]=e},toString:function(){return JSON.stringify(this.data)},isEmpty:function(){return!this.data||0==Object.keys(this.data).length}}},"text/plain":function(){return{append:function(t,e){return this.data=this.data||[],this.data.push(e)},toString:function(){return this.data.join("")},isEmpty:function(){return!this.data||0==this.data.length}}}},h=t=>null==t,b=(...t)=>{for(var e=0;e<t.length;e++)if(null!==t[e]&&void 0!==t[e])return t[e];return null},v=(t,e,r,n)=>i(this,void 0,void 0,(function*(){return o(t,e).then((function(t){var e;return i(this,void 0,void 0,(function*(){try{var i=t.headers.get("Content-Type")||"";let o;try{o=t.type}catch(t){}let a={statusCode:t.status,statusText:t.statusText,headers:t.headers,type:o,ok:t.ok},s={"application/json":"json","text/plain":"text","(multipart/form-data|application/x-www-form-urlencoded)":"formData",blob:"blob",text:"text"},l=Object.keys(s).find((t=>new RegExp(t).test(i)))||"text";if(a[s[l]]=yield t[s[l]](),a.message=(null===(e=null==a?void 0:a.json)||void 0===e?void 0:e.message)||(t.ok?"Success.":"Something went wrong."),!t.ok)throw a;if(r.on_success){let t=r.on_success(a,n);if(void 0!==t)return t}return a}catch(t){if(r.on_error){let e=r.on_error(t,n);if(void 0!==e)return e}return Promise.reject(t)}}))}))}));function _(t,e,r){t.method=(t.method||"get").toUpperCase(),t.params=t.params||{};const n=function(o){var a,s,l,k,w,g;return i(this,void 0,void 0,(function*(){if(this instanceof n)throw new Error("This is an endpoint, you can't initialize this.");var i=c(u,e);i.on_request=t.on_request||i.on_request,i.on_success=t.on_success||i.on_success,i.on_error=t.on_error||i.on_error;var O=`${i.base}${t.path}`;((null==o?void 0:o.$sandbox)||(null===(a=null==i?void 0:i.values)||void 0===a?void 0:a.$sandbox))&&(O=`${i.sandboxBase||i.base}${t.path}`);var T,C,A={method:t.method,headers:Object.assign({},i.headers),agent:i.fetch_agent},E=p.includes(t.enctype)?t.enctype:d[t.enctype||"json"],S=Object.assign({},i.params,t.params),N=m[E](),D=new URLSearchParams;for(var R in"FormData"==(null===(s=null==o?void 0:o.constructor)||void 0===s?void 0:s.name)?(T=o,o=Object.fromEntries(Array.from(T.keys(),(t=>t.endsWith("[]")?[t.slice(0,-2),T.getAll(t)]:[t,T.get(t)])))):o=o||{},S){var P=S[R],j=o[R],U=null===(l=null==i?void 0:i.values)||void 0===l?void 0:l[R],x=P.default,M=(null==o?void 0:o.$sandbox)||(null===(k=null==i?void 0:i.values)||void 0===k?void 0:k.$sandbox)?P.example:void 0,B=b(j,U,M,x),X=P.name||R,L=P.help||`The '${R}' field is invalid.`;if(P.required&&h(B))throw(I=new Error(L)).field=R,I;if(!h(B)){if("function"==typeof P.format)try{B=P.format(B)}catch(t){throw(I=new Error(t.message||L)).field=R,I}if(P.type&&"any"!==P.type&&((I=new Error(L)).field=R,["string","boolean","number"].includes(P.type)&&typeof B!=P.type||"array"==P.type&&!Array.isArray(B)||"object"==P.type&&(!B||"Object"!==B.__proto__.constructor.name)))throw I;if(P.validate&&("RegExp"==(null===(g=null===(w=P.validate)||void 0===w?void 0:w.constructor)||void 0===g?void 0:g.name)&&(P.validate.toJSON=function(){return P.validate.toString().replace(/^\//g,"").replace(/\/$/g,"")}),!new RegExp(P.validate).test(B)))throw(I=new Error(L)).field=R,I;if("number"==P.type){var I;if(P.hasOwnProperty("max")&&!isNaN(P.max)&&Number(B)>Number(P.max))throw(I=new Error(`The maximum allowed value allowed for the ${X} parameter is ${P.max}`)).field=R,I;if(P.hasOwnProperty("min")&&!isNaN(P.min)&&Number(B)<Number(P.min))throw(I=new Error(`The minimum allowed value allowed for the ${X} parameter is ${P.min}`)).field=R,I}if(P.in&&Array.isArray(P.in)&&!P.in.includes(B))throw(I=new Error(`The ${X} parameter should be one of these values: ${P.in}`)).field=R,I;var $="string"==typeof P.location?P.location.toLowerCase():f[A.method];if(!$||!y.includes($))throw new Error(`Invalid location for '${R}' field.`);"headers"!=$?"body"!=$?"query"!=$?"path"==$&&(O=O.replace(new RegExp(`{${(C=X,C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).trim()}}`),B)):D.append(X,B):N.append(X,B):(A.headers=A.headers||{},A.headers[X]=B)}}var F=D.toString();F&&(O=`${O}?${F}`),N.keys&&(t=>{for(var e of t)return!1;return!0})(N.keys())||N.getLengthSync&&0==N.getLengthSync()||N.isEmpty&&N.isEmpty()||(A.body=N.toString()),A.body&&"multipart/form-data"!==E&&(A.headers=A.headers||{},A.headers["Content-Type"]=E);let H={url:O,options:A,params:o,key:r,instance:u.__$root_instance__,self:_(t,e,r)};if(i.on_request){var G=yield Promise.resolve(i.on_request(H));if(G){if(!(null==G?void 0:G.url)&&!(null==G?void 0:G.options))return G;O=G.url||O,A=G.options||A}if(!1===G)return!1}return v(O,A,i,H)}))};return n}function k(e,r,i,o){var a={[e=e||"Rests"]:function(s){if(!(this instanceof a[e]))throw new Error("This is a category, you can initalize this category to update values using 'new' command.");if(o)throw new Error("This is already initialized, you can use 'set' instead.");let d=c(u,r),p=l(s),y=c(d,p);return n(i?(f=t,i.split(".").reduce(((t,e)=>null==t?void 0:t[e]),f)):t,y);var f}};return o&&(a[e].set=function(t){if(this instanceof a[e].set)throw new Error("The set object can't be initialized.");let r=l(t);return c(u,r,!0),a[e]}),a[e]}const w=Object.defineProperty(k("Rests",u,void 0,!0),"__schema__",{value:{schema:t,options:u},writable:!1,enumerable:!1});return u.__$root_instance__=w,function t(e,r,i,n){for(var o in r){var a=r[o];if(!a||"object"!=typeof a)continue;if(void 0!==e[o]){console.warn(`Skipping ${o} as it confilicts with another key in the object`);continue}let l=`${n?n+".":""}${o}`;if(a.hasOwnProperty("path")){var s=a;e[o]=_(s,i,l)}else{if("$"===o.substr(0,1))continue;let r=i;(null==a?void 0:a.$options)&&(r=c(i,null==a?void 0:a.$options)),e[o]=t(k(o,r,l),a,r,l)}}return e}(w,t,{})}Object.defineProperty(e,"__esModule",{value:!0}),n.default=n,e.default=n,t.exports=n},203:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(r(945)),a=r(382);let s,l;const c=(0,o.default)({binance:{$options:{base:"https://api.binance.com/api/v3"},bookTicker:{path:"/ticker/bookTicker",on_success:t=>t.json},ticker:{path:"/ticker/price",on_request(t){return i(this,void 0,void 0,(function*(){if(!l){const e=yield t.instance.binance.bookTicker();l=e.map((t=>parseFloat(t.askPrice)<=0&&t.symbol)).filter((t=>t))}}))},on_success(t,e){const r={USDT:"USD",USDC:"USD",BUSD:"USD"},i=t.json;if(!i||!Array.isArray(i))throw new Error(`Invalid response from Binance: ${JSON.stringify(i)}`);return i.reduce(((t,e)=>{if(l&&-1!==l.indexOf(e.symbol))return t;const i=(0,a.symbolMap)(e.symbol,r),n=parseFloat(e.price);return t[i]=n,t}),{})}}},bitfinex:{$options:{base:"https://api-pub.bitfinex.com/v2"},ticker:{path:"/tickers",params:{symbols:{help:"The symbols you want information about as a comma separated list, or ALL for every symbol. (Examples of possible symbols: tBTCUSD, tETHUSD, fUSD, fBTC)",default:"ALL",type:"string"}},on_success:function(t){const e={BAB:"BCH",DSH:"DASH"},r=t.json;if(!r||!Array.isArray(r))throw new Error(`Invalid response from Bitfinex: ${JSON.stringify(r)}`);return r.reduce(((t,r)=>{if(!r[0].startsWith("t"))return t;const i=(0,a.symbolMap)(r[0].replace(/^t/,""),e,!0).replace(":",""),n=parseFloat(r[7]);return t[i]=n,t}),{})}}},coinbase:{$options:{base:"https://api.coinbase.com/v2"},ticker:{path:"/exchange-rates",params:{currency:{help:"The exchange currency (default USD)"}},on_success:t=>{var e;const r=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.data;if(!r)throw new Error(`Invalid response from Coinbase: ${r}`);return Object.keys(r.rates).reduce(((t,e,i)=>{const n=e+r.currency,o=(0,a.formatNumber)(1/parseFloat(r.rates[e]),8);return t[n]=o,t}),{})}}},kraken:{$options:{base:"https://api.kraken.com/0/public"},pairs:{path:"/AssetPairs",on_success:t=>Object.keys(t.json.result)},ticker:{path:"/Ticker",on_request:t=>i(void 0,void 0,void 0,(function*(){if(!s){const e=yield t.instance.kraken.pairs();s=e}return{url:t.url+"?pair="+s}})),on_success:t=>{var e;const r={XETC:"ETC",XETH:"ETH",XLTC:"LTC",XMLN:"MLN",XREP:"REP",XXBT:"BTC",XXDG:"XDG",XXLM:"XLM",XXMR:"XMR",XXRP:"XRP",XZEC:"ZEC",XBT:"BTC",ZAUD:"AUD",ZEUR:"EUR",ZGBP:"GBP",ZUSD:"USD",ZCAD:"CAD",ZJPY:"JPY"},i=null===(e=t.json)||void 0===e?void 0:e.result;if(!i)throw new Error(`Invalid response from Kraken: ${JSON.stringify(i)}`);return Object.keys(i).reduce(((t,e)=>{const n=(0,a.symbolMap)(e,r,!0),o=parseFloat(i[e].c[0]);return t[n]=o,t}),{})}}},coinmarketcap:{$options:{base:"https://api.coinmarketcap.com/data-api/v3"},top:{path:"/map/all",params:{limit:{default:"150"},listing_status:{default:"active"}},on_success:function(t){const e=t.json;if(!e||!e.data||!Array.isArray(e.data.cryptoCurrencyMap))throw new Error(`Invalid response from CoinMarketCap: ${JSON.stringify(e)}`);return e.data.cryptoCurrencyMap.reduce(((t,e)=>(t[e.symbol]={id:e.id,title:e.name,symbol:e.symbol,logo:`https://s2.coinmarketcap.com/static/img/coins/128x128/${e.id}.png`,rank:e.rank},t)),{})}}},fiat:{all:{path:"https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml",on_success:function(t){var e=t.text,r=e.match(/(?<=currency=["'])([A-Za-z]+)/gi),i=e.match(/(?<=rate=["'])([.0-9]+)/gi),n=r.reduce(((t,e,r)=>Object.assign(Object.assign({},t),{[e]:i[r]})),{});return n.EUR=1,n}}},coinconvert:{$options:{base:"https://api.coinconvert.net"},ticker:{path:"/v2/ticker",params:{v:{default:"2.0.5"},filterExchanges:{type:"array"},noAverage:{type:"boolean"}},on_success:t=>t.json},list:{path:"/v2/list?v=2.0.5",on_success:t=>t.json}}});e.default=c},866:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(r(827));e.default=class{constructor(){this.ticker={},this.list=[],this.workers={},this.workersPromises=[]}ready(){return i(this,void 0,void 0,(function*(){return Promise.all(this.workersPromises)}))}addCurrency(t,e,r,n){return i(this,void 0,void 0,(function*(){if("string"!=typeof t||"string"!=typeof e||!o.default.list.fiat.includes(e))throw new Error("Invalid currency pair.");if("function"!=typeof r)throw new Error("No function specified.");if(t=t.toUpperCase(),e=e.toUpperCase(),(this.ticker[t+e]||this.ticker[e+t]||-1!=this.list.indexOf(t))&&(console.warn("This custom currency already exists, it will be overriden."),this.removeCurrency(t)),this.list.push(t),n){if("number"!=typeof n)throw new Error("Invalid interval specfied.");this.workers[t+e]=setInterval((()=>Promise.resolve(r()).then((r=>{this.ticker[t+e]=Number(r)}))),n)}const i=Promise.resolve(r()).then((r=>{this.ticker[t+e]=Number(r)}));return this.workersPromises.push(i),i}))}removeCurrency(t,e){t=t.toUpperCase(),e=e?e.toUpperCase():"";for(const r in this.workers)r.includes(t+e)&&(clearInterval(this.workers[r]),delete this.ticker[r]);this.list=this.list.filter((e=>e!==t))}}},382:(t,e)=>{function r(t,e){if("number"!=typeof t&&(t=Number(t),isNaN(t)))return NaN;let r="number"==typeof e?t.toFixed(e):t+"",i=r.match(/\./)?r.replace(/0+$/g,"").replace(/\.+$/g,""):r;return parseFloat(i)}Object.defineProperty(e,"__esModule",{value:!0}),e.isEmpty=e.formatNumber=e.getAverage=e.symbolMap=void 0,e.symbolMap=function t(e,r,i=!1){const n=Object.keys(r);for(var o=0;o<n.length;o++)if(e.length>=n[o].length+3&&(e.endsWith(n[o])||e.startsWith(n[o]))){const a=e.replace(n[o],r[n[o]]);return i?t(a,r,!1):a}return e},e.getAverage=function(t){return t.length?t.flatMap((t=>Object.keys(t))).filter(((t,e,r)=>r.indexOf(t)==e)).reduce(((e,i)=>{let n=t.map((t=>t[i])).filter((t=>t)),o=r(n.reduce(((t,e)=>t+e),0)/n.length,8);return e[i]=o,e}),{}):{}},e.formatNumber=r,e.isEmpty=function(t){if(!t)return!0;for(var e in t)return!1;return!0}},607:function(module,exports,__webpack_require__){var __createBinding=this&&this.__createBinding||(Object.create?function(t,e,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(e,r);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,n)}:function(t,e,r,i){void 0===i&&(i=r),t[i]=e[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&__createBinding(e,t,r);return __setModuleDefault(e,t),e},__awaiter=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))},__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});const helpers_1=__webpack_require__(382),worker_1=__importStar(__webpack_require__(827)),custom_1=__importDefault(__webpack_require__(866)),CustomWorkers=new custom_1.default,ConvertObject=function(){const convert={get isReady(){return worker_1.default.isReady},get list(){return{crypto:worker_1.default.list.crypto.concat(CustomWorkers.list),fiat:worker_1.default.list.fiat}},get cryptoInfo(){return worker_1.default.cryptoInfo},get lastUpdated(){return worker_1.default.data.crypto.last_updated},get ticker(){return worker_1.default.data}},getPrice=function(t,e="USD"){var r=CustomWorkers.ticker[t+e]||(CustomWorkers.ticker[e+t]?1/CustomWorkers.ticker[e+t]:null),i=worker_1.default.data.crypto.current[t+e]||(worker_1.default.data.crypto.current[e+t]?1/worker_1.default.data.crypto.current[e+t]:null);return r||i},wrapper=function(t,e){var r=e;return function(e){if((0,helpers_1.isEmpty)(worker_1.default.data.crypto.current)||(0,helpers_1.isEmpty)(worker_1.default.data.fiat.current))return console.warn("[~] Prices are loading.\nYou should use `await convert.ready()` to make sure prices are loaded before calling convert."),!1;if(!e)return!1;if(e=(0,helpers_1.formatNumber)(e),isNaN(e))return!1;const i=worker_1.default.data.fiat.current,n=worker_1.default.list.crypto.concat(CustomWorkers.list);if(r==t)return e;if(n.includes(t)&&n.includes(r)){let i=getPrice(t,r)||wrapper("USD",r)(wrapper(t,"USD")(1));return(0,helpers_1.formatNumber)(i*e,8)}if(i[t]&&i[r])return(0,helpers_1.formatNumber)(e/i[t]*i[r],4);var o=function(t){return getPrice(t)||wrapper("BTC","USD")(getPrice(t,"BTC"))||wrapper("ETH","USD")(getPrice(t,"ETH"))};if(i[r]){let n=o(t)/i.USD*i[r];return(0,helpers_1.formatNumber)(n*e,8)}if(i[t]){let n=o(r)/i.USD*i[t];return(0,helpers_1.formatNumber)(e/n,8)}return null}},initialize=function(){let types="";types+="type amount = (amount: number | string) => number | false | null;",types+="\nexport interface Pairs {";const all_currencies=worker_1.default.list.crypto.concat(worker_1.default.list.fiat,CustomWorkers.list);for(var i=0;i<all_currencies.length;i++){var coin=all_currencies[i];if(coin&&"string"==typeof coin){convert[coin]||(convert[coin]={}),types+=`\n\t'${coin.replace(/\'/g,"\\'")}': {`;for(var a=0;a<all_currencies.length;a++){var currency=all_currencies[a];currency&&"string"==typeof currency&&(convert[coin][currency]=wrapper(coin,currency),types+=`\n\t\t'${currency.replace(/\'/g,"\\'")}': amount,`)}types+="\n},"}}types+="\n}","undefined"==typeof window&&"undefined"!=typeof process&&function(){__awaiter(this,void 0,void 0,(function*(){try{eval("\n\t\t\t\t\t\tconst fs = require('fs');\n\t\t\t\t\t\tconst path = require('path');\n\t\t\t\t\t\tconst isDist = path.basename(__dirname) == 'dist';\n\t\t\t\t\t\tconst typesFile = path.join(__dirname, isDist ? 'paris.d.ts' : 'paris.ts');\n\n\t\t\t\t\t\tfs.writeFileSync(typesFile, types, 'utf-8');\n\t\t\t\t\t")}catch(t){console.warn(t)}}))}()};return convert.setOptions=function(t){let e=worker_1.default.setOptions(t);if((t.crypto_interval||t.fiat_interval)&&(t.crypto_interval!==worker_1.default.options.crypto_interval||t.fiat_interval!==worker_1.default.options.fiat_interval)){let t=e.restart();return convert.ready=function(){return __awaiter(this,void 0,void 0,(function*(){return yield Promise.resolve(t),yield Promise.resolve(CustomWorkers.ready()),convert}))},t}return e},convert.stop=function(){return worker_1.default.stop()},convert.start=function(){let t=worker_1.default.restart();return convert.ready=function(){return __awaiter(this,void 0,void 0,(function*(){return yield Promise.resolve(t),yield Promise.resolve(CustomWorkers.ready()),convert}))},t},convert.ready=function(){return __awaiter(this,void 0,void 0,(function*(){return yield Promise.resolve(worker_1.WorkerReady),yield Promise.resolve(CustomWorkers.ready()),convert}))},convert.addCurrency=(t,...e)=>{if(convert.hasOwnProperty(t))throw new Error("This property already exists.");return Promise.resolve(CustomWorkers.addCurrency.apply(CustomWorkers,[t,...e])).then((()=>{worker_1.default.isReady&&initialize()}))},convert.removeCurrency=(t,e)=>{var r,i;if(CustomWorkers.list.includes(t)){delete convert[t];const e=worker_1.default.list.crypto.concat(worker_1.default.list.fiat,CustomWorkers.list);for(const n of e)(null===(r=convert[n])||void 0===r?void 0:r[t])&&(null===(i=convert[n])||void 0===i||delete i[t])}return CustomWorkers.removeCurrency(t,e)},Promise.resolve(worker_1.WorkerReady).then((()=>initialize())),convert}(),convert=ConvertObject;convert.default=convert,module.exports&&(module.exports=convert),exports.default=convert},827:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}l((i=i.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.WorkerReady=void 0;const o=n(r(203)),a=r(382),s="undefined"!=typeof window&&window.document;function l(t={}){this.exchanges=["binance","bitfinex","coinbase","kraken"],this.list={crypto:["BTC","ETH","USDT","USDC","BNB","XRP","BUSD","ADA","SOL","DOGE","DOT","DAI","MATIC","SHIB","TRX","AVAX","UNI","WBTC","LEO","LTC","ETC","LINK","ATOM","FTT","XLM","NEAR","CRO","XMR","ALGO","BCH","LUNC","FLOW","QNT","VET","TON","FIL","APE","ICP","CHZ","HBAR","MANA","XTZ","SAND","EOS","EGLD","THETA","AAVE","AXS","OKB","USDP","BSV","KCS","TUSD","ZEC","MIOTA","XEC","USDD","MKR","BTT","HT","GRT","USDN","HNT","CAKE","NEO","KLAY","FTM","SNX","PAXG","RUNE","NEXO","LDO","CRV","GT","DASH","ENJ","BAT","COMP","STX","KAVA","RVN","ZIL","WAVES","FEI","MINA","RSR","XDC","LRC","GMT","DCR","TWT","CELO","XEM","BTG","KSM","HOT","1INCH","CEL","CVX","BNX","AR","GNO","LUNA","ROSE","ENS","USTC","GUSD","QTUM","YFI","ANKR","TFUEL","GALA","GLM","IOTX","KDA","BTRST","ONE","OMG","BAL","ZRX","LPT","POLY","JST","FLUX","ICX","BORA","IOST","HIVE","AMP","OP","KNC","XYM","SRM","ONT","WAXP","STORJ","MXC","CSPR","IMX","SC","ZEN","AUDIO","GLMR","SXP","XCH","ABBC","CHSB","VGX","UMA","WOO"],fiat:["USD","JPY","BGN","CZK","DKK","GBP","HUF","PLN","RON","SEK","CHF","ISK","NOK","HRK","RUB","TRY","AUD","BRL","CAD","CNY","HKD","IDR","ILS","INR","KRW","MXN","MYR","NZD","PHP","SGD","THB","ZAR","EUR"]},this.cryptoInfo=[{id:1,title:"Bitcoin",symbol:"BTC",rank:1},{id:1027,title:"Ethereum",symbol:"ETH",rank:2},{id:825,title:"Tether",symbol:"USDT",rank:3},{id:3408,title:"USD Coin",symbol:"USDC",rank:4},{id:1839,title:"BNB",symbol:"BNB",rank:5},{id:52,title:"XRP",symbol:"XRP",rank:6},{id:4687,title:"Binance USD",symbol:"BUSD",rank:7},{id:2010,title:"Cardano",symbol:"ADA",rank:8},{id:5426,title:"Solana",symbol:"SOL",rank:9},{id:74,title:"Dogecoin",symbol:"DOGE",rank:10},{id:6636,title:"Polkadot",symbol:"DOT",rank:11},{id:4943,title:"Dai",symbol:"DAI",rank:12},{id:3890,title:"Polygon",symbol:"MATIC",rank:13},{id:5994,title:"Shiba Inu",symbol:"SHIB",rank:14},{id:1958,title:"TRON",symbol:"TRX",rank:15},{id:5805,title:"Avalanche",symbol:"AVAX",rank:16},{id:7083,title:"Uniswap",symbol:"UNI",rank:17},{id:3717,title:"Wrapped Bitcoin",symbol:"WBTC",rank:18},{id:3957,title:"UNUS SED LEO",symbol:"LEO",rank:19},{id:2,title:"Litecoin",symbol:"LTC",rank:20},{id:1321,title:"Ethereum Classic",symbol:"ETC",rank:21},{id:1975,title:"Chainlink",symbol:"LINK",rank:22},{id:3794,title:"Cosmos",symbol:"ATOM",rank:23},{id:4195,title:"FTX Token",symbol:"FTT",rank:24},{id:512,title:"Stellar",symbol:"XLM",rank:25},{id:6535,title:"NEAR Protocol",symbol:"NEAR",rank:26},{id:3635,title:"Cronos",symbol:"CRO",rank:27},{id:328,title:"Monero",symbol:"XMR",rank:28},{id:4030,title:"Algorand",symbol:"ALGO",rank:29},{id:1831,title:"Bitcoin Cash",symbol:"BCH",rank:30},{id:4172,title:"Terra Classic",symbol:"LUNC",rank:31},{id:4558,title:"Flow",symbol:"FLOW",rank:32},{id:3155,title:"Quant",symbol:"QNT",rank:33},{id:3077,title:"VeChain",symbol:"VET",rank:34},{id:11419,title:"Toncoin",symbol:"TON",rank:35},{id:2280,title:"Filecoin",symbol:"FIL",rank:36},{id:18876,title:"ApeCoin",symbol:"APE",rank:37},{id:8916,title:"Internet Computer",symbol:"ICP",rank:38},{id:4066,title:"Chiliz",symbol:"CHZ",rank:39},{id:4642,title:"Hedera",symbol:"HBAR",rank:40},{id:1966,title:"Decentraland",symbol:"MANA",rank:41},{id:2011,title:"Tezos",symbol:"XTZ",rank:42},{id:6210,title:"The Sandbox",symbol:"SAND",rank:43},{id:1765,title:"EOS",symbol:"EOS",rank:44},{id:6892,title:"Elrond",symbol:"EGLD",rank:45},{id:2416,title:"Theta Network",symbol:"THETA",rank:46},{id:7278,title:"Aave",symbol:"AAVE",rank:47},{id:6783,title:"Axie Infinity",symbol:"AXS",rank:48},{id:3897,title:"OKB",symbol:"OKB",rank:49},{id:3330,title:"Pax Dollar",symbol:"USDP",rank:50},{id:3602,title:"Bitcoin SV",symbol:"BSV",rank:51},{id:2087,title:"KuCoin Token",symbol:"KCS",rank:52},{id:2563,title:"TrueUSD",symbol:"TUSD",rank:53},{id:1437,title:"Zcash",symbol:"ZEC",rank:54},{id:1720,title:"IOTA",symbol:"MIOTA",rank:55},{id:10791,title:"eCash",symbol:"XEC",rank:56},{id:19891,title:"USDD",symbol:"USDD",rank:57},{id:1518,title:"Maker",symbol:"MKR",rank:58},{id:16086,title:"BitTorrent-New",symbol:"BTT",rank:59},{id:2502,title:"Huobi Token",symbol:"HT",rank:60},{id:6719,title:"The Graph",symbol:"GRT",rank:61},{id:5068,title:"Neutrino USD",symbol:"USDN",rank:62},{id:5665,title:"Helium",symbol:"HNT",rank:63},{id:7186,title:"PancakeSwap",symbol:"CAKE",rank:64},{id:1376,title:"Neo",symbol:"NEO",rank:65},{id:4256,title:"Klaytn",symbol:"KLAY",rank:66},{id:3513,title:"Fantom",symbol:"FTM",rank:67},{id:2586,title:"Synthetix",symbol:"SNX",rank:68},{id:4705,title:"PAX Gold",symbol:"PAXG",rank:69},{id:4157,title:"THORChain",symbol:"RUNE",rank:70},{id:2694,title:"Nexo",symbol:"NEXO",rank:71},{id:8e3,title:"Lido DAO",symbol:"LDO",rank:72},{id:6538,title:"Curve DAO Token",symbol:"CRV",rank:73},{id:4269,title:"GateToken",symbol:"GT",rank:74},{id:131,title:"Dash",symbol:"DASH",rank:75},{id:2130,title:"Enjin Coin",symbol:"ENJ",rank:76},{id:1697,title:"Basic Attention Token",symbol:"BAT",rank:77},{id:5692,title:"Compound",symbol:"COMP",rank:78},{id:4847,title:"Stacks",symbol:"STX",rank:79},{id:4846,title:"Kava",symbol:"KAVA",rank:80},{id:2577,title:"Ravencoin",symbol:"RVN",rank:81},{id:2469,title:"Zilliqa",symbol:"ZIL",rank:82},{id:1274,title:"Waves",symbol:"WAVES",rank:83},{id:8642,title:"Fei USD",symbol:"FEI",rank:84},{id:8646,title:"Mina",symbol:"MINA",rank:85},{id:3964,title:"Reserve Rights",symbol:"RSR",rank:86},{id:2634,title:"XDC Network",symbol:"XDC",rank:87},{id:1934,title:"Loopring",symbol:"LRC",rank:88},{id:18069,title:"STEPN",symbol:"GMT",rank:89},{id:1168,title:"Decred",symbol:"DCR",rank:90},{id:5964,title:"Trust Wallet Token",symbol:"TWT",rank:91},{id:5567,title:"Celo",symbol:"CELO",rank:92},{id:873,title:"NEM",symbol:"XEM",rank:93},{id:2083,title:"Bitcoin Gold",symbol:"BTG",rank:94},{id:5034,title:"Kusama",symbol:"KSM",rank:95},{id:2682,title:"Holo",symbol:"HOT",rank:96},{id:8104,title:"1inch Network",symbol:"1INCH",rank:97},{id:2700,title:"Celsius",symbol:"CEL",rank:98},{id:9903,title:"Convex Finance",symbol:"CVX",rank:99},{id:9891,title:"BinaryX",symbol:"BNX",rank:100},{id:5632,title:"Arweave",symbol:"AR",rank:101},{id:1659,title:"Gnosis",symbol:"GNO",rank:102},{id:20314,title:"Terra",symbol:"LUNA",rank:103},{id:7653,title:"Oasis Network",symbol:"ROSE",rank:104},{id:13855,title:"Ethereum Name Service",symbol:"ENS",rank:105},{id:7129,title:"TerraClassicUSD",symbol:"USTC",rank:106},{id:3306,title:"Gemini Dollar",symbol:"GUSD",rank:107},{id:1684,title:"Qtum",symbol:"QTUM",rank:108},{id:5864,title:"yearn.finance",symbol:"YFI",rank:109},{id:3783,title:"Ankr",symbol:"ANKR",rank:110},{id:3822,title:"Theta Fuel",symbol:"TFUEL",rank:111},{id:7080,title:"Gala",symbol:"GALA",rank:112},{id:1455,title:"Golem",symbol:"GLM",rank:113},{id:2777,title:"IoTeX",symbol:"IOTX",rank:114},{id:5647,title:"Kadena",symbol:"KDA",rank:115},{id:11584,title:"Braintrust",symbol:"BTRST",rank:116},{id:3945,title:"Harmony",symbol:"ONE",rank:117},{id:1808,title:"OMG Network",symbol:"OMG",rank:118},{id:5728,title:"Balancer",symbol:"BAL",rank:119},{id:1896,title:"0x",symbol:"ZRX",rank:120},{id:3640,title:"Livepeer",symbol:"LPT",rank:121},{id:2496,title:"Polymath",symbol:"POLY",rank:122},{id:5488,title:"JUST",symbol:"JST",rank:123},{id:3029,title:"Flux",symbol:"FLUX",rank:124},{id:2099,title:"ICON",symbol:"ICX",rank:125},{id:3801,title:"BORA",symbol:"BORA",rank:126},{id:2405,title:"IOST",symbol:"IOST",rank:127},{id:5370,title:"Hive",symbol:"HIVE",rank:128},{id:6945,title:"Amp",symbol:"AMP",rank:129},{id:11840,title:"Optimism",symbol:"OP",rank:130},{id:9444,title:"Kyber Network Crystal v2",symbol:"KNC",rank:131},{id:8677,title:"Symbol",symbol:"XYM",rank:132},{id:6187,title:"Serum",symbol:"SRM",rank:133},{id:2566,title:"Ontology",symbol:"ONT",rank:134},{id:2300,title:"WAX",symbol:"WAXP",rank:135},{id:1772,title:"Storj",symbol:"STORJ",rank:136},{id:3628,title:"MXC",symbol:"MXC",rank:137},{id:5899,title:"Casper",symbol:"CSPR",rank:138},{id:10603,title:"Immutable X",symbol:"IMX",rank:139},{id:1042,title:"Siacoin",symbol:"SC",rank:140},{id:1698,title:"Horizen",symbol:"ZEN",rank:141},{id:7455,title:"Audius",symbol:"AUDIO",rank:142},{id:6836,title:"Moonbeam",symbol:"GLMR",rank:143},{id:4279,title:"SXP",symbol:"SXP",rank:144},{id:9258,title:"Chia",symbol:"XCH",rank:145},{id:3437,title:"ABBC Coin",symbol:"ABBC",rank:146},{id:2499,title:"SwissBorg",symbol:"CHSB",rank:147},{id:1817,title:"Voyager Token",symbol:"VGX",rank:148},{id:5617,title:"UMA",symbol:"UMA",rank:149},{id:7501,title:"WOO Network",symbol:"WOO",rank:150}].reduce(((t,e)=>(t[e.symbol]=Object.assign(Object.assign({},t),{logo:`https://s2.coinmarketcap.com/static/img/coins/128x128/${e.id}.png`}),t)),{}),this.data={crypto:{last_updated:null,current:null},fiat:{last_updated:null,current:null}},this.options=Object.assign(Object.assign({crypto_interval:s?15e3:5e3,fiat_interval:36e5,calculateAverage:!0,onUpdate:void 0},this.exchanges.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:!0})),{})),t),this.log=function(){var t,e;!s&&(null===(e=null===(t=null===process||void 0===process?void 0:process.env)||void 0===t?void 0:t.NODE_ENV)||void 0===e?void 0:e.startsWith("dev"))&&Array.from(arguments).forEach((t=>{console.log(t)}))},this.isReady=!1}l.prototype.setOptions=function(t){let e="function"==typeof t?t(Object.assign({},this.options)):t||{};s&&!isNaN(e.crypto_interval)&&e.crypto_interval<1e4&&console.warn("The minimum allowed interval on frontend is 10s.");let r=!1,i=e.hasOwnProperty("calculateAverage")&&e.calculateAverage!==this.options.calculateAverage;for(const t of this.exchanges)if(e.hasOwnProperty(t)&&e[t]!==this.options[t]){r=!0;break}if(this.options=Object.assign(Object.assign(Object.assign({},this.options),e),{crypto_interval:isNaN(e.crypto_interval)?this.options.crypto_interval:Math.max(s?1e4:1e3,e.crypto_interval),fiat_interval:isNaN(e.fiat_interval)?this.options.fiat_interval:Math.max(18e5,e.fiat_interval)}),s){if(r||i)return this.browserTicker()}else this.data.crypto.current=this.joinPrices(this.data);return this},l.prototype.updateCrypto=function(){return i(this,void 0,void 0,(function*(){this.data.crypto.last_updated||this.log("Updating crypto...");const t=this.exchanges.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:o.default[e].ticker})),{});let e=[],r={};for(const i in t)try{this.data.crypto[i]=yield t[i](),this.options[i]&&(e.push(this.data.crypto[i]),r=Object.assign(Object.assign({},r),this.data.crypto[i]),this.data.crypto.last_updated=+new Date)}catch(t){this.data.crypto[i]=null,console.error(`Failed fetching prices from ${i}`,t)}return e.length&&(this.data.crypto.current=this.options.calculateAverage?Object.assign(Object.assign({},r),(0,a.getAverage)(e)):r,"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data.crypto)),this}))},l.prototype.updateFiat=function(){return i(this,void 0,void 0,(function*(){this.log("Updating fiat...");try{this.data.fiat.current=yield o.default.fiat.all(),this.data.fiat.last_updated=+new Date,"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data.fiat,!0)}catch(t){console.error("Failed fetching fiat prices from ECB",t)}return this}))},l.prototype.updateLists=function(){return i(this,void 0,void 0,(function*(){this.log("Updating top currency list...");try{const t=yield o.default.coinmarketcap.top();this.list.crypto=Object.keys(t),this.cryptoInfo=t}catch(t){console.error("Failed fetching fiat prices from ECB",t)}return this}))},l.prototype.joinPrices=function(t){const e=this.exchanges.reduce(((e,r)=>Object.assign(Object.assign({},e),{[r]:t.crypto[r]})),{});let r=[],i={};for(const t in e)this.options[t]&&e[t]&&(r.push(e[t]),i=Object.assign(Object.assign({},i),e[t]));return this.options.calculateAverage?Object.assign(Object.assign({},i),(0,a.getAverage)(r)):i},l.prototype.browserTicker=function(){return i(this,void 0,void 0,(function*(){try{const t=this.options,e=this.exchanges.filter((e=>!t[e])),r=yield o.default.coinconvert.ticker(e.length?{filterExchanges:e,noAverage:!this.options.calculateAverage||void 0}:{});this.data=r,"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data)}catch(t){console.error("Failed fetching prices from API",t)}return this}))},l.prototype.runBrowser=function(){var t,e;return i(this,void 0,void 0,(function*(){if("undefined"!=typeof window&&window.__ccRunning)throw new Error("The crypto-convert worker seems to be already running. \n\t\t\t- There might be an issue with the way your app imports javascript dependencies. \n\t\t\t- Make sure to call 'convert.stop()' on component unmounts if you are using SPA frameworks (e.g React).");if(!(null===(e=null===(t=this.data)||void 0===t?void 0:t.crypto)||void 0===e?void 0:e.current)){yield this.browserTicker();const t=yield o.default.coinconvert.list();this.list.crypto=Object.keys(t.crypto),this.list.fiat=t.fiat,this.cryptoInfo=t.crypto}return this.isReady=!0,this.crypto_worker&&clearInterval(this.crypto_worker),this.crypto_worker=setInterval(this.browserTicker.bind(this),this.options.crypto_interval),"undefined"!=typeof window&&(window.__ccRunning=!0,window.__ccRunID&&clearInterval(window.__ccRunID),window.__ccRunID=this.crypto_worker),this}))},l.prototype.runServer=function(){return i(this,void 0,void 0,(function*(){return yield this.updateLists(),yield this.updateFiat(),yield this.updateCrypto(),this.isReady=!0,this.crypto_worker=setInterval(this.updateCrypto.bind(this),this.options.crypto_interval),this.fiat_worker=setInterval(this.updateFiat.bind(this),this.options.fiat_interval),this}))},l.prototype.run=function(){return this.isRunning=!0,s?this.runBrowser():this.runServer()},l.prototype.stop=function(){return clearInterval(this.crypto_worker),clearInterval(this.fiat_worker),this.isRunning=!1,"undefined"!=typeof window&&(window.__ccRunning=!1),this},l.prototype.restart=function(){return this.stop().run()};const c=new l;e.WorkerReady=c.run(),e.default=c},88:t=>{t.exports=__WEBPACK_EXTERNAL_MODULE__88__},265:t=>{t.exports=__WEBPACK_EXTERNAL_MODULE__265__}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var r=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__=__webpack_require__(607);return __webpack_exports__})()));
/*! For license information please see crypto-convert.min.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("FormData"),require("fetch")):"function"==typeof define&&define.amd?define(["FormData","fetch"],e):"object"==typeof exports?exports.CryptoConvert=e(require("FormData"),require("fetch")):t.CryptoConvert=e(t.FormData,t.fetch)}(this,((__WEBPACK_EXTERNAL_MODULE__88__,__WEBPACK_EXTERNAL_MODULE__265__)=>(()=>{"use strict";var __webpack_modules__={945:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))};function n(t,e){const o="undefined"!=typeof window?null===window||void 0===window?void 0:window.fetch:r(265),s="undefined"!=typeof window?null===window||void 0===window?void 0:window.FormData:r(88);if(!o)throw new Error("Fetch API is not installed. If you are using Node please run `npm install node-fetch`");if(!s)throw new Error("FormData is not installed. If you are using Node please run `npm install form-data`");const a=t=>Object.assign(Object.assign({},t),{headers:Object.assign({},t.headers),params:Object.assign({},t.params),values:Object.assign({},t.values)}),l=t=>{var e,r;if("Object"!=(null===(r=null===(e=null==t?void 0:t.__proto__)||void 0===e?void 0:e.constructor)||void 0===r?void 0:r.name))throw new Error("Invalid $options object.");let i=a(t.$options||{});return delete t.$options,Object.assign(Object.assign({},i),{values:Object.assign(Object.assign({},i.values),t)})},c=(t,e,r=!1)=>{let i=r?t||{}:a(t||{}),n=a(e||{});return n.headers=Object.assign(Object.assign({},i.headers),n.headers),n.params=Object.assign(Object.assign({},i.params),n.params),n.values=Object.assign(Object.assign({},i.values),n.values),Object.assign(i,n),i};t=Object.assign({},t);let d={base:"",headers:{"User-Agent":"Rests JS (v1.1.0)"},params:{},values:{},on_error:void 0,on_success:void 0,on_request:void 0,fetch_agent:null};c(d,(null==t?void 0:t.$options)||{},!0),c(d,e,!0);const u={json:"application/json",form:"multipart/form-data",urlencoded:"application/x-www-form-urlencoded",text:"text/plain"},p=Object.values(u),h=["headers","body","query","path"],y={POST:"body",GET:"query"},f={"multipart/form-data":function(){var t=new s;return t.toString=function(){return this},t},"application/x-www-form-urlencoded":function(){return new URLSearchParams},"application/json":function(){return{append:function(t,e){this.data=this.data||{},this.data[t]=e},toString:function(){return JSON.stringify(this.data)},isEmpty:function(){return!this.data||0==Object.keys(this.data).length}}},"text/plain":function(){return{append:function(t,e){return this.data=this.data||[],this.data.push(e)},toString:function(){return this.data.join("")},isEmpty:function(){return!this.data||0==this.data.length}}}},m=t=>null==t,b=(...t)=>{for(var e=0;e<t.length;e++)if(null!==t[e]&&void 0!==t[e])return t[e];return null},k=(t,e,r,n)=>i(this,void 0,void 0,(function*(){return o(t,e).then((function(t){var e;return i(this,void 0,void 0,(function*(){try{var i=t.headers.get("Content-Type")||"";let o;try{o=t.type}catch(t){}let s={statusCode:t.status,statusText:t.statusText,headers:t.headers,type:o,ok:t.ok},a={"application/json":"json","text/plain":"text","(multipart/form-data|application/x-www-form-urlencoded)":"formData",blob:"blob",text:"text"},l=Object.keys(a).find((t=>new RegExp(t).test(i)))||"text";if(s[a[l]]=yield t[a[l]](),s.message=(null===(e=null==s?void 0:s.json)||void 0===e?void 0:e.message)||(t.ok?"Success.":"Something went wrong."),!t.ok)throw s;if(r.on_success){let t=r.on_success(s,n);if(void 0!==t)return t}return s}catch(t){if(r.on_error){let e=r.on_error(t,n);if(void 0!==e)return e}return Promise.reject(t)}}))}))}));function v(t,e,r){t.method=(t.method||"get").toUpperCase(),t.params=t.params||{};const n=function(o){var s,a,l,w,_,g;return i(this,void 0,void 0,(function*(){if(this instanceof n)throw new Error("This is an endpoint, you can't initialize this.");var i=c(d,e);i.on_request=t.on_request||i.on_request,i.on_success=t.on_success||i.on_success,i.on_error=t.on_error||i.on_error;var C=`${i.base}${t.path}`;((null==o?void 0:o.$sandbox)||(null===(s=null==i?void 0:i.values)||void 0===s?void 0:s.$sandbox))&&(C=`${i.sandboxBase||i.base}${t.path}`);var T,O,A={method:t.method,headers:Object.assign({},i.headers),agent:i.fetch_agent},S=p.includes(t.enctype)?t.enctype:u[t.enctype||"json"],E=Object.assign({},i.params,t.params),N=f[S](),R=new URLSearchParams;for(var D in"FormData"==(null===(a=null==o?void 0:o.constructor)||void 0===a?void 0:a.name)?(T=o,o=Object.fromEntries(Array.from(T.keys(),(t=>t.endsWith("[]")?[t.slice(0,-2),T.getAll(t)]:[t,T.get(t)])))):o=o||{},E){var P=E[D],I=o[D],L=null===(l=null==i?void 0:i.values)||void 0===l?void 0:l[D],U=P.default,B=(null==o?void 0:o.$sandbox)||(null===(w=null==i?void 0:i.values)||void 0===w?void 0:w.$sandbox)?P.example:void 0,j=b(I,L,B,U),x=P.name||D,X=P.help||`The '${D}' field is invalid.`;if(P.required&&m(j))throw(M=new Error(X)).field=D,M;if(!m(j)){if("function"==typeof P.format)try{j=P.format(j)}catch(t){throw(M=new Error(t.message||X)).field=D,M}if(P.type&&"any"!==P.type&&((M=new Error(X)).field=D,["string","boolean","number"].includes(P.type)&&typeof j!=P.type||"array"==P.type&&!Array.isArray(j)||"object"==P.type&&(!j||"Object"!==j.__proto__.constructor.name)))throw M;if(P.validate&&("RegExp"==(null===(g=null===(_=P.validate)||void 0===_?void 0:_.constructor)||void 0===g?void 0:g.name)&&(P.validate.toJSON=function(){return P.validate.toString().replace(/^\//g,"").replace(/\/$/g,"")}),!new RegExp(P.validate).test(j)))throw(M=new Error(X)).field=D,M;if("number"==P.type){var M;if(P.hasOwnProperty("max")&&!isNaN(P.max)&&Number(j)>Number(P.max))throw(M=new Error(`The maximum allowed value allowed for the ${x} parameter is ${P.max}`)).field=D,M;if(P.hasOwnProperty("min")&&!isNaN(P.min)&&Number(j)<Number(P.min))throw(M=new Error(`The minimum allowed value allowed for the ${x} parameter is ${P.min}`)).field=D,M}if(P.in&&Array.isArray(P.in)&&!P.in.includes(j))throw(M=new Error(`The ${x} parameter should be one of these values: ${P.in}`)).field=D,M;var H="string"==typeof P.location?P.location.toLowerCase():y[A.method];if(!H||!h.includes(H))throw new Error(`Invalid location for '${D}' field.`);"headers"!=H?"body"!=H?"query"!=H?"path"==H&&(C=C.replace(new RegExp(`{${(O=x,O.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).trim()}}`),j)):R.append(x,j):N.append(x,j):(A.headers=A.headers||{},A.headers[x]=j)}}var $=R.toString();$&&(C=`${C}?${$}`),N.keys&&(t=>{for(var e of t)return!1;return!0})(N.keys())||N.getLengthSync&&0==N.getLengthSync()||N.isEmpty&&N.isEmpty()||(A.body=N.toString()),A.body&&"multipart/form-data"!==S&&(A.headers=A.headers||{},A.headers["Content-Type"]=S);let F={url:C,options:A,params:o,key:r,instance:d.__$root_instance__,self:v(t,e,r)};if(i.on_request){var G=yield Promise.resolve(i.on_request(F));if(G){if(!(null==G?void 0:G.url)&&!(null==G?void 0:G.options))return G;C=G.url||C,A=G.options||A}if(!1===G)return!1}return k(C,A,i,F)}))};return n}function w(e,r,i,o){var s={[e=e||"Rests"]:function(a){if(!(this instanceof s[e]))throw new Error("This is a category, you can initalize this category to update values using 'new' command.");if(o)throw new Error("This is already initialized, you can use 'set' instead.");let u=c(d,r),p=l(a),h=c(u,p);return n(i?(y=t,i.split(".").reduce(((t,e)=>null==t?void 0:t[e]),y)):t,h);var y}};return o&&(s[e].set=function(t){if(this instanceof s[e].set)throw new Error("The set object can't be initialized.");let r=l(t);return c(d,r,!0),s[e]}),s[e]}const _=Object.defineProperty(w("Rests",d,void 0,!0),"__schema__",{value:{schema:t,options:d},writable:!1,enumerable:!1});return d.__$root_instance__=_,function t(e,r,i,n){for(var o in r){var s=r[o];if(!s||"object"!=typeof s)continue;if(void 0!==e[o]){console.warn(`Skipping ${o} as it confilicts with another key in the object`);continue}let l=`${n?n+".":""}${o}`;if(s.hasOwnProperty("path")){var a=s;e[o]=v(a,i,l)}else{if("$"===o.substr(0,1))continue;let r=i;(null==s?void 0:s.$options)&&(r=c(i,null==s?void 0:s.$options)),e[o]=t(w(o,r,l),s,r,l)}}return e}(_,t,{})}Object.defineProperty(e,"__esModule",{value:!0}),n.default=n,e.default=n,t.exports=n},203:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const o=n(r(945)),s=r(382);let a,l;const c=(0,o.default)({binance:{$options:{base:"https://api.binance.com/api/v3"},bookTicker:{path:"/ticker/bookTicker",on_success:t=>t.json},ticker:{path:"/ticker/price",on_request(t){return i(this,void 0,void 0,(function*(){if(!l){const e=yield t.instance.binance.bookTicker();l=e.map((t=>parseFloat(t.askPrice)<=0&&t.symbol)).filter((t=>t))}}))},on_success(t,e){const r={USDT:"USD",USDC:"USD",BUSD:"USD"},i=t.json;if(!i||!Array.isArray(i))throw new Error(`Invalid response from Binance: ${JSON.stringify(i)}`);return i.reduce(((t,e)=>{if(l&&-1!==l.indexOf(e.symbol))return t;const i=(0,s.symbolMap)(e.symbol,r),n=parseFloat(e.price);return t[i]=n,t}),{})}}},bitfinex:{$options:{base:"https://api-pub.bitfinex.com/v2"},ticker:{path:"/tickers",params:{symbols:{help:"The symbols you want information about as a comma separated list, or ALL for every symbol. (Examples of possible symbols: tBTCUSD, tETHUSD, fUSD, fBTC)",default:"ALL",type:"string"}},on_success:function(t){const e={BAB:"BCH",DSH:"DASH"},r=t.json;if(!r||!Array.isArray(r))throw new Error(`Invalid response from Bitfinex: ${JSON.stringify(r)}`);return r.reduce(((t,r)=>{if(!r[0].startsWith("t"))return t;const i=(0,s.symbolMap)(r[0].replace(/^t/,""),e,!0).replace(":",""),n=parseFloat(r[7]);return t[i]=n,t}),{})}}},coinbase:{$options:{base:"https://api.coinbase.com/v2"},ticker:{path:"/exchange-rates",params:{currency:{help:"The exchange currency (default USD)"}},on_success:t=>{var e;const r=null===(e=null==t?void 0:t.json)||void 0===e?void 0:e.data;if(!r)throw new Error(`Invalid response from Coinbase: ${r}`);return Object.keys(r.rates).reduce(((t,e,i)=>{const n=e+r.currency,o=(0,s.formatNumber)(1/parseFloat(r.rates[e]),8);return t[n]=o,t}),{})}}},kraken:{$options:{base:"https://api.kraken.com/0/public"},pairs:{path:"/AssetPairs",on_success:t=>Object.keys(t.json.result)},ticker:{path:"/Ticker",on_request:t=>i(void 0,void 0,void 0,(function*(){if(!a){const e=yield t.instance.kraken.pairs();a=e}return{url:t.url+"?pair="+a}})),on_success:t=>{var e;const r={XETC:"ETC",XETH:"ETH",XLTC:"LTC",XMLN:"MLN",XREP:"REP",XXBT:"BTC",XXDG:"XDG",XXLM:"XLM",XXMR:"XMR",XXRP:"XRP",XZEC:"ZEC",XBT:"BTC",ZAUD:"AUD",ZEUR:"EUR",ZGBP:"GBP",ZUSD:"USD",ZCAD:"CAD",ZJPY:"JPY"},i=null===(e=t.json)||void 0===e?void 0:e.result;if(!i)throw new Error(`Invalid response from Kraken: ${JSON.stringify(i)}`);return Object.keys(i).reduce(((t,e)=>{const n=(0,s.symbolMap)(e,r,!0),o=parseFloat(i[e].c[0]);return t[n]=o,t}),{})}}},coinmarketcap:{$options:{base:"https://api.coinmarketcap.com/data-api/v3"},top:{path:"/map/all",params:{limit:{default:"150"},listing_status:{default:"active"}},on_success:function(t){const e=t.json;if(!e||!e.data||!Array.isArray(e.data.cryptoCurrencyMap))throw new Error(`Invalid response from CoinMarketCap: ${JSON.stringify(e)}`);return e.data.cryptoCurrencyMap.reduce(((t,e)=>(t[e.symbol]={id:e.id,title:e.name,symbol:e.symbol,logo:`https://s2.coinmarketcap.com/static/img/coins/128x128/${e.id}.png`,rank:e.rank},t)),{})}}},fiat:{all:{path:"https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml",on_success:function(t){var e=t.text,r=e.match(/(?<=currency=["'])([A-Za-z]+)/gi),i=e.match(/(?<=rate=["'])([.0-9]+)/gi),n=r.reduce(((t,e,r)=>Object.assign(Object.assign({},t),{[e]:i[r]})),{});return n.EUR=1,n}}},coinconvert:{$options:{base:"https://api.coinconvert.net"},ticker:{path:"/v2/ticker",params:{v:{default:"2.1.0"},filterExchanges:{type:"array"},noAverage:{type:"boolean"}},on_success:t=>t.json},list:{path:"/v2/list?v=2.1.0",on_success:t=>t.json}}});e.default=c},866:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0});const n=r(827);e.default=class{constructor(){this.ticker={},this.list=[],this.workers={},this.workersPromises=[]}ready(){return i(this,void 0,void 0,(function*(){return Promise.all(this.workersPromises)}))}addCurrency(t,e,r,o){return i(this,void 0,void 0,(function*(){if("string"!=typeof t||"string"!=typeof e||!n.initialCoinList.fiat.includes(e))throw new Error("Invalid currency pair.");if("function"!=typeof r)throw new Error("No function specified.");if(t=t.toUpperCase(),e=e.toUpperCase(),(this.ticker[t+e]||this.ticker[e+t]||-1!=this.list.indexOf(t))&&(console.warn("This custom currency already exists, it will be overriden."),this.removeCurrency(t)),this.list.push(t),o){if("number"!=typeof o)throw new Error("Invalid interval specfied.");this.workers[t+e]=setInterval((()=>Promise.resolve(r()).then((r=>{this.ticker[t+e]=Number(r)}))),o)}const i=Promise.resolve(r()).then((r=>{this.ticker[t+e]=Number(r)}));return this.workersPromises.push(i),i}))}removeCurrency(t,e){t=t.toUpperCase(),e=e?e.toUpperCase():"";for(const r in this.workers)r.includes(t+e)&&(clearInterval(this.workers[r]),delete this.ticker[r]);this.list=this.list.filter((e=>e!==t))}}},382:(t,e)=>{function r(t,e){if("number"!=typeof t&&(t=Number(t),isNaN(t)))return NaN;let r="number"==typeof e?t.toFixed(e):t+"",i=r.match(/\./)?r.replace(/0+$/g,"").replace(/\.+$/g,""):r;return parseFloat(i)}Object.defineProperty(e,"__esModule",{value:!0}),e.isBrowser=e.isEmpty=e.formatNumber=e.getAverage=e.symbolMap=void 0,e.symbolMap=function t(e,r,i=!1){const n=Object.keys(r);for(var o=0;o<n.length;o++)if(e.length>=n[o].length+3&&(e.endsWith(n[o])||e.startsWith(n[o]))){const s=e.replace(n[o],r[n[o]]);return i?t(s,r,!1):s}return e},e.getAverage=function(t){return t.length?t.flatMap((t=>Object.keys(t))).filter(((t,e,r)=>r.indexOf(t)==e)).reduce(((e,i)=>{let n=t.map((t=>t[i])).filter((t=>t)),o=r(n.reduce(((t,e)=>t+e),0)/n.length,8);return e[i]=o,e}),{}):{}},e.formatNumber=r,e.isEmpty=function(t){if(!t)return!0;for(var e in t)return!1;return!0},e.isBrowser="undefined"!=typeof window&&window.document},607:function(module,exports,__webpack_require__){var __awaiter=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});const helpers_1=__webpack_require__(382),worker_1=__importDefault(__webpack_require__(827)),custom_1=__importDefault(__webpack_require__(866)),customWorkers=new custom_1.default;class CryptoConvert{constructor(t={}){if(helpers_1.isBrowser){if(window.__ccInitialized)throw new Error("You have already initalized one instance of crypto-convert. You cannot initialize multiple instances.");window.__ccInitialized=!0}this.worker=new worker_1.default(t),this.workerReady=this.worker.run(),this.internalMethods=Object.keys(this),Promise.resolve(this.workerReady).then((()=>{this.populate(),this.worker.onCryptoListRefresh=()=>{this.populate()}}))}getPrice(t,e="USD"){var r=customWorkers.ticker[t+e]||(customWorkers.ticker[e+t]?1/customWorkers.ticker[e+t]:null),i=this.worker.data.crypto.current[t+e]||(this.worker.data.crypto.current[e+t]?1/this.worker.data.crypto.current[e+t]:null);return r||i}wrapper(t,e){var r=e;return function(e){if((0,helpers_1.isEmpty)(this.worker.data.crypto.current)||(0,helpers_1.isEmpty)(this.worker.data.fiat.current))return console.warn("[~] Prices are loading.\nYou should use `await convert.ready()` to make sure prices are loaded before calling convert."),!1;if(!e)return!1;if(e=(0,helpers_1.formatNumber)(e),isNaN(e))return!1;const i=this.worker.data.fiat.current,n=this.worker.list.crypto.concat(customWorkers.list);if(r==t)return e;if(n.includes(t)&&n.includes(r)){let i=this.getPrice(t,r)||this.wrapper("USD",r)(this.wrapper(t,"USD")(1));return(0,helpers_1.formatNumber)(i*e,8)}if(i[t]&&i[r])return(0,helpers_1.formatNumber)(e/i[t]*i[r],4);var o=function(t){return this.getPrice(t)||this.wrapper("BTC","USD")(this.getPrice(t,"BTC"))||this.wrapper("ETH","USD")(this.getPrice(t,"ETH"))}.bind(this);if(i[r]){let n=o(t)/i.USD*i[r];return(0,helpers_1.formatNumber)(n*e,8)}if(i[t]){let n=o(r)/i.USD*i[t];return(0,helpers_1.formatNumber)(e/n,8)}return null}.bind(this)}isSafeKey(t){return!this.internalMethods.includes(t)&&!t.startsWith("__")&&!function(){}[t]}populate(){let types="";types+="type amount = (amount: number | string) => number | false | null;",types+="\nexport interface Pairs {";const all_currencies=this.worker.list.crypto.concat(this.worker.list.fiat,customWorkers.list);for(var i=0;i<all_currencies.length;i++){var coin=all_currencies[i];if(coin&&"string"==typeof coin&&this.isSafeKey(coin)){this[coin]||(this[coin]={}),types+=`\n\t'${coin.replace(/\'/g,"\\'")}': {`;for(var a=0;a<all_currencies.length;a++){var currency=all_currencies[a];currency&&"string"==typeof currency&&this.isSafeKey(coin)&&(this[coin][currency]=this.wrapper(coin,currency),types+=`\n\t\t'${currency.replace(/\'/g,"\\'")}': amount,`)}types+="\n},"}}types+="\n}","undefined"==typeof window&&"undefined"!=typeof process&&function(){__awaiter(this,void 0,void 0,(function*(){try{eval("\n\t\t\t\t\t\tconst fs = require('fs');\n\t\t\t\t\t\tconst path = require('path');\n\t\t\t\t\t\tconst isDist = path.basename(__dirname) == 'dist';\n\t\t\t\t\t\tconst typesFile = path.join(__dirname, isDist ? 'paris.d.ts' : 'paris.ts');\n\n\t\t\t\t\t\tfs.writeFileSync(typesFile, types, 'utf-8');\n\t\t\t\t\t")}catch(t){console.warn(t)}}))}()}get isReady(){return this.worker.isReady}get list(){return{crypto:this.worker.list.crypto.concat(customWorkers.list),fiat:this.worker.list.fiat}}get cryptoInfo(){return this.worker.cryptoInfo}get lastUpdated(){return this.worker.data.crypto.last_updated}get ticker(){return this.worker.data}setOptions(t){if((t.cryptoInterval||t.fiatInterval)&&(t.cryptoInterval!==this.worker.options.cryptoInterval||t.fiatInterval!==this.worker.options.fiatInterval)||t.hasOwnProperty("refreshCryptoList")&&t.refreshCryptoList!==this.worker.options.refreshCryptoList||t.hasOwnProperty("serverSideCCAPI")&&t.serverSideCCAPI!==this.worker.options.serverSideCCAPI){if(!this.worker.isReady)throw new Error("You cannot set these options here because CryptoConvert is not ready yet. Instead set the options on the constructor parameter.");return this.workerReady=Promise.resolve(this.worker.setOptions(t)).then((()=>this.worker.restart())),this.worker}return this.worker.setOptions(t)}stop(){return this.worker.stop()}restart(){return this.workerReady=this.worker.restart(),this.workerReady}ready(){return __awaiter(this,void 0,void 0,(function*(){return yield Promise.resolve(this.workerReady),yield Promise.resolve(customWorkers.ready()),this}))}addCurrency(t,...e){return __awaiter(this,void 0,void 0,(function*(){if(this.hasOwnProperty(t))throw new Error("This property already exists.");return Promise.resolve(customWorkers.addCurrency.apply(customWorkers,[t,...e])).then((()=>{this.worker.isReady&&this.populate()}))}))}removeCurrency(t,e){var r,i;if(customWorkers.list.includes(t)&&this.isSafeKey(t)){delete this[t];const e=this.worker.list.crypto.concat(this.worker.list.fiat,customWorkers.list);for(const n of e)(null===(r=this[n])||void 0===r?void 0:r[t])&&(null===(i=this[n])||void 0===i||delete i[t])}return customWorkers.removeCurrency(t,e)}}CryptoConvert.default=CryptoConvert,module.exports&&(module.exports=CryptoConvert),exports.default=CryptoConvert},827:function(t,e,r){var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((i=i.apply(t,e||[])).next())}))},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.initialCoinList=void 0;const o=n(r(203)),s=r(382);e.initialCoinList={crypto:["BTC","ETH","USDT","USDC","BNB","XRP","BUSD","ADA","SOL","DOGE","DOT","DAI","MATIC","SHIB","TRX","AVAX","UNI","WBTC","LEO","LTC","ETC","LINK","ATOM","FTT","XLM","NEAR","CRO","XMR","ALGO","BCH","LUNC","FLOW","QNT","VET","TON","FIL","APE","ICP","CHZ","HBAR","MANA","XTZ","SAND","EOS","EGLD","THETA","AAVE","AXS","OKB","USDP","BSV","KCS","TUSD","ZEC","MIOTA","XEC","USDD","MKR","BTT","HT","GRT","USDN","HNT","CAKE","NEO","KLAY","FTM","SNX","PAXG","RUNE","NEXO","LDO","CRV","GT","DASH","ENJ","BAT","COMP","STX","KAVA","RVN","ZIL","WAVES","FEI","MINA","RSR","XDC","LRC","GMT","DCR","TWT","CELO","XEM","BTG","KSM","HOT","1INCH","CEL","CVX","BNX","AR","GNO","LUNA","ROSE","ENS","USTC","GUSD","QTUM","YFI","ANKR","TFUEL","GALA","GLM","IOTX","KDA","BTRST","ONE","OMG","BAL","ZRX","LPT","POLY","JST","FLUX","ICX","BORA","IOST","HIVE","AMP","OP","KNC","XYM","SRM","ONT","WAXP","STORJ","MXC","CSPR","IMX","SC","ZEN","AUDIO","GLMR","SXP","XCH","ABBC","CHSB","VGX","UMA","WOO"],fiat:["USD","JPY","BGN","CZK","DKK","GBP","HUF","PLN","RON","SEK","CHF","ISK","NOK","HRK","RUB","TRY","AUD","BRL","CAD","CNY","HKD","IDR","ILS","INR","KRW","MXN","MYR","NZD","PHP","SGD","THB","ZAR","EUR"]},e.default=class{constructor(t={}){this.exchanges=["binance","bitfinex","coinbase","kraken"],this.list=e.initialCoinList,this.cryptoInfo=[{id:1,title:"Bitcoin",symbol:"BTC",rank:1},{id:1027,title:"Ethereum",symbol:"ETH",rank:2},{id:825,title:"Tether",symbol:"USDT",rank:3},{id:3408,title:"USD Coin",symbol:"USDC",rank:4},{id:1839,title:"BNB",symbol:"BNB",rank:5},{id:52,title:"XRP",symbol:"XRP",rank:6},{id:4687,title:"Binance USD",symbol:"BUSD",rank:7},{id:2010,title:"Cardano",symbol:"ADA",rank:8},{id:5426,title:"Solana",symbol:"SOL",rank:9},{id:74,title:"Dogecoin",symbol:"DOGE",rank:10},{id:6636,title:"Polkadot",symbol:"DOT",rank:11},{id:4943,title:"Dai",symbol:"DAI",rank:12},{id:3890,title:"Polygon",symbol:"MATIC",rank:13},{id:5994,title:"Shiba Inu",symbol:"SHIB",rank:14},{id:1958,title:"TRON",symbol:"TRX",rank:15},{id:5805,title:"Avalanche",symbol:"AVAX",rank:16},{id:7083,title:"Uniswap",symbol:"UNI",rank:17},{id:3717,title:"Wrapped Bitcoin",symbol:"WBTC",rank:18},{id:3957,title:"UNUS SED LEO",symbol:"LEO",rank:19},{id:2,title:"Litecoin",symbol:"LTC",rank:20},{id:1321,title:"Ethereum Classic",symbol:"ETC",rank:21},{id:1975,title:"Chainlink",symbol:"LINK",rank:22},{id:3794,title:"Cosmos",symbol:"ATOM",rank:23},{id:4195,title:"FTX Token",symbol:"FTT",rank:24},{id:512,title:"Stellar",symbol:"XLM",rank:25},{id:6535,title:"NEAR Protocol",symbol:"NEAR",rank:26},{id:3635,title:"Cronos",symbol:"CRO",rank:27},{id:328,title:"Monero",symbol:"XMR",rank:28},{id:4030,title:"Algorand",symbol:"ALGO",rank:29},{id:1831,title:"Bitcoin Cash",symbol:"BCH",rank:30},{id:4172,title:"Terra Classic",symbol:"LUNC",rank:31},{id:4558,title:"Flow",symbol:"FLOW",rank:32},{id:3155,title:"Quant",symbol:"QNT",rank:33},{id:3077,title:"VeChain",symbol:"VET",rank:34},{id:11419,title:"Toncoin",symbol:"TON",rank:35},{id:2280,title:"Filecoin",symbol:"FIL",rank:36},{id:18876,title:"ApeCoin",symbol:"APE",rank:37},{id:8916,title:"Internet Computer",symbol:"ICP",rank:38},{id:4066,title:"Chiliz",symbol:"CHZ",rank:39},{id:4642,title:"Hedera",symbol:"HBAR",rank:40},{id:1966,title:"Decentraland",symbol:"MANA",rank:41},{id:2011,title:"Tezos",symbol:"XTZ",rank:42},{id:6210,title:"The Sandbox",symbol:"SAND",rank:43},{id:1765,title:"EOS",symbol:"EOS",rank:44},{id:6892,title:"Elrond",symbol:"EGLD",rank:45},{id:2416,title:"Theta Network",symbol:"THETA",rank:46},{id:7278,title:"Aave",symbol:"AAVE",rank:47},{id:6783,title:"Axie Infinity",symbol:"AXS",rank:48},{id:3897,title:"OKB",symbol:"OKB",rank:49},{id:3330,title:"Pax Dollar",symbol:"USDP",rank:50},{id:3602,title:"Bitcoin SV",symbol:"BSV",rank:51},{id:2087,title:"KuCoin Token",symbol:"KCS",rank:52},{id:2563,title:"TrueUSD",symbol:"TUSD",rank:53},{id:1437,title:"Zcash",symbol:"ZEC",rank:54},{id:1720,title:"IOTA",symbol:"MIOTA",rank:55},{id:10791,title:"eCash",symbol:"XEC",rank:56},{id:19891,title:"USDD",symbol:"USDD",rank:57},{id:1518,title:"Maker",symbol:"MKR",rank:58},{id:16086,title:"BitTorrent-New",symbol:"BTT",rank:59},{id:2502,title:"Huobi Token",symbol:"HT",rank:60},{id:6719,title:"The Graph",symbol:"GRT",rank:61},{id:5068,title:"Neutrino USD",symbol:"USDN",rank:62},{id:5665,title:"Helium",symbol:"HNT",rank:63},{id:7186,title:"PancakeSwap",symbol:"CAKE",rank:64},{id:1376,title:"Neo",symbol:"NEO",rank:65},{id:4256,title:"Klaytn",symbol:"KLAY",rank:66},{id:3513,title:"Fantom",symbol:"FTM",rank:67},{id:2586,title:"Synthetix",symbol:"SNX",rank:68},{id:4705,title:"PAX Gold",symbol:"PAXG",rank:69},{id:4157,title:"THORChain",symbol:"RUNE",rank:70},{id:2694,title:"Nexo",symbol:"NEXO",rank:71},{id:8e3,title:"Lido DAO",symbol:"LDO",rank:72},{id:6538,title:"Curve DAO Token",symbol:"CRV",rank:73},{id:4269,title:"GateToken",symbol:"GT",rank:74},{id:131,title:"Dash",symbol:"DASH",rank:75},{id:2130,title:"Enjin Coin",symbol:"ENJ",rank:76},{id:1697,title:"Basic Attention Token",symbol:"BAT",rank:77},{id:5692,title:"Compound",symbol:"COMP",rank:78},{id:4847,title:"Stacks",symbol:"STX",rank:79},{id:4846,title:"Kava",symbol:"KAVA",rank:80},{id:2577,title:"Ravencoin",symbol:"RVN",rank:81},{id:2469,title:"Zilliqa",symbol:"ZIL",rank:82},{id:1274,title:"Waves",symbol:"WAVES",rank:83},{id:8642,title:"Fei USD",symbol:"FEI",rank:84},{id:8646,title:"Mina",symbol:"MINA",rank:85},{id:3964,title:"Reserve Rights",symbol:"RSR",rank:86},{id:2634,title:"XDC Network",symbol:"XDC",rank:87},{id:1934,title:"Loopring",symbol:"LRC",rank:88},{id:18069,title:"STEPN",symbol:"GMT",rank:89},{id:1168,title:"Decred",symbol:"DCR",rank:90},{id:5964,title:"Trust Wallet Token",symbol:"TWT",rank:91},{id:5567,title:"Celo",symbol:"CELO",rank:92},{id:873,title:"NEM",symbol:"XEM",rank:93},{id:2083,title:"Bitcoin Gold",symbol:"BTG",rank:94},{id:5034,title:"Kusama",symbol:"KSM",rank:95},{id:2682,title:"Holo",symbol:"HOT",rank:96},{id:8104,title:"1inch Network",symbol:"1INCH",rank:97},{id:2700,title:"Celsius",symbol:"CEL",rank:98},{id:9903,title:"Convex Finance",symbol:"CVX",rank:99},{id:9891,title:"BinaryX",symbol:"BNX",rank:100},{id:5632,title:"Arweave",symbol:"AR",rank:101},{id:1659,title:"Gnosis",symbol:"GNO",rank:102},{id:20314,title:"Terra",symbol:"LUNA",rank:103},{id:7653,title:"Oasis Network",symbol:"ROSE",rank:104},{id:13855,title:"Ethereum Name Service",symbol:"ENS",rank:105},{id:7129,title:"TerraClassicUSD",symbol:"USTC",rank:106},{id:3306,title:"Gemini Dollar",symbol:"GUSD",rank:107},{id:1684,title:"Qtum",symbol:"QTUM",rank:108},{id:5864,title:"yearn.finance",symbol:"YFI",rank:109},{id:3783,title:"Ankr",symbol:"ANKR",rank:110},{id:3822,title:"Theta Fuel",symbol:"TFUEL",rank:111},{id:7080,title:"Gala",symbol:"GALA",rank:112},{id:1455,title:"Golem",symbol:"GLM",rank:113},{id:2777,title:"IoTeX",symbol:"IOTX",rank:114},{id:5647,title:"Kadena",symbol:"KDA",rank:115},{id:11584,title:"Braintrust",symbol:"BTRST",rank:116},{id:3945,title:"Harmony",symbol:"ONE",rank:117},{id:1808,title:"OMG Network",symbol:"OMG",rank:118},{id:5728,title:"Balancer",symbol:"BAL",rank:119},{id:1896,title:"0x",symbol:"ZRX",rank:120},{id:3640,title:"Livepeer",symbol:"LPT",rank:121},{id:2496,title:"Polymath",symbol:"POLY",rank:122},{id:5488,title:"JUST",symbol:"JST",rank:123},{id:3029,title:"Flux",symbol:"FLUX",rank:124},{id:2099,title:"ICON",symbol:"ICX",rank:125},{id:3801,title:"BORA",symbol:"BORA",rank:126},{id:2405,title:"IOST",symbol:"IOST",rank:127},{id:5370,title:"Hive",symbol:"HIVE",rank:128},{id:6945,title:"Amp",symbol:"AMP",rank:129},{id:11840,title:"Optimism",symbol:"OP",rank:130},{id:9444,title:"Kyber Network Crystal v2",symbol:"KNC",rank:131},{id:8677,title:"Symbol",symbol:"XYM",rank:132},{id:6187,title:"Serum",symbol:"SRM",rank:133},{id:2566,title:"Ontology",symbol:"ONT",rank:134},{id:2300,title:"WAX",symbol:"WAXP",rank:135},{id:1772,title:"Storj",symbol:"STORJ",rank:136},{id:3628,title:"MXC",symbol:"MXC",rank:137},{id:5899,title:"Casper",symbol:"CSPR",rank:138},{id:10603,title:"Immutable X",symbol:"IMX",rank:139},{id:1042,title:"Siacoin",symbol:"SC",rank:140},{id:1698,title:"Horizen",symbol:"ZEN",rank:141},{id:7455,title:"Audius",symbol:"AUDIO",rank:142},{id:6836,title:"Moonbeam",symbol:"GLMR",rank:143},{id:4279,title:"SXP",symbol:"SXP",rank:144},{id:9258,title:"Chia",symbol:"XCH",rank:145},{id:3437,title:"ABBC Coin",symbol:"ABBC",rank:146},{id:2499,title:"SwissBorg",symbol:"CHSB",rank:147},{id:1817,title:"Voyager Token",symbol:"VGX",rank:148},{id:5617,title:"UMA",symbol:"UMA",rank:149},{id:7501,title:"WOO Network",symbol:"WOO",rank:150}].reduce(((t,e)=>(t[e.symbol]=Object.assign(Object.assign({},t),{logo:`https://s2.coinmarketcap.com/static/img/coins/128x128/${e.id}.png`}),t)),{}),this.data={crypto:{last_updated:null,current:null},fiat:{last_updated:null,current:null}},this.options=Object.assign({cryptoInterval:s.isBrowser?15e3:5e3,fiatInterval:36e5,calculateAverage:!0,onUpdate:void 0,serverSideCCAPI:!1,refreshCryptoList:!0},this.exchanges.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:!0})),{})),this.isReady=!1,this.isRunning=!1,this.options=Object.assign(Object.assign({},this.options),t),t.hasOwnProperty("HTTPAgent")&&o.default.set({$options:{fetch_agent:t.HTTPAgent}})}log(...t){var e,r;!s.isBrowser&&(null===(r=null===(e=null===process||void 0===process?void 0:process.env)||void 0===e?void 0:e.NODE_ENV)||void 0===r?void 0:r.startsWith("dev"))&&Array.from(arguments).forEach((t=>{console.log(t)}))}setOptions(t){let e="function"==typeof t?t(Object.assign({},this.options)):t||{};s.isBrowser&&!isNaN(e.cryptoInterval)&&e.cryptoInterval<1e4&&console.warn("The minimum allowed interval on frontend is 10s."),e.hasOwnProperty("HTTPAgent")&&o.default.set({$options:{fetch_agent:e.HTTPAgent}});let r=!1,i=e.hasOwnProperty("calculateAverage")&&e.calculateAverage!==this.options.calculateAverage;for(const t of this.exchanges)if(e.hasOwnProperty(t)&&e[t]!==this.options[t]){r=!0;break}if(this.options=Object.assign(Object.assign(Object.assign({},this.options),e),{cryptoInterval:isNaN(e.cryptoInterval)?this.options.cryptoInterval:Math.max(s.isBrowser?1e4:1e3,e.cryptoInterval),fiatInterval:isNaN(e.fiatInterval)?this.options.fiatInterval:Math.max(18e5,e.fiatInterval)}),s.isBrowser||this.options.serverSideCCAPI){if(r||i)return this.browserTicker()}else this.data.crypto.current=this.joinPrices(this.data);return this}updateCrypto(){return i(this,void 0,void 0,(function*(){this.data.crypto.last_updated||this.log("Updating crypto...");const t=this.exchanges.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:o.default[e].ticker})),{});let e=[],r={};for(const i in t)try{this.data.crypto[i]=yield t[i](),this.options[i]&&(e.push(this.data.crypto[i]),r=Object.assign(Object.assign({},r),this.data.crypto[i]),this.data.crypto.last_updated=+new Date)}catch(t){this.data.crypto[i]=null,console.error(`Failed fetching prices from ${i}`,t)}return e.length&&(this.data.crypto.current=this.options.calculateAverage?Object.assign(Object.assign({},r),(0,s.getAverage)(e)):r,"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data.crypto)),this}))}updateFiat(){return i(this,void 0,void 0,(function*(){this.log("Updating fiat...");try{this.data.fiat.current=yield o.default.fiat.all(),this.data.fiat.last_updated=+new Date,"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data.fiat,!0)}catch(t){console.error("Failed fetching fiat prices from ECB",t)}return this}))}updateLists(){return i(this,void 0,void 0,(function*(){this.data.crypto.last_updated||this.log("Updating top currency list...");try{const t=yield o.default.coinmarketcap.top();this.list.crypto=Object.keys(t),this.cryptoInfo=t,"function"==typeof this.onCryptoListRefresh&&this.isReady&&this.onCryptoListRefresh(this.list.crypto)}catch(t){console.error("Failed fetching fiat prices from ECB",t)}return this}))}joinPrices(t){const e=this.exchanges.reduce(((e,r)=>Object.assign(Object.assign({},e),{[r]:t.crypto[r]})),{});let r=[],i={};for(const t in e)this.options[t]&&e[t]&&(r.push(e[t]),i=Object.assign(Object.assign({},i),e[t]));return this.options.calculateAverage?Object.assign(Object.assign({},i),(0,s.getAverage)(r)):i}browserTicker(){return i(this,void 0,void 0,(function*(){try{const t=this.options,e=this.exchanges.filter((e=>!t[e])),r=yield o.default.coinconvert.ticker(e.length?{filterExchanges:e,noAverage:!this.options.calculateAverage||void 0}:{});this.data=r,"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data)}catch(t){console.error("Failed fetching prices from API",t)}return this}))}browserLists(){return i(this,void 0,void 0,(function*(){try{const t=yield o.default.coinconvert.list();this.list.crypto=Object.keys(t.crypto),this.list.fiat=t.fiat,this.cryptoInfo=t.crypto,"function"==typeof this.onCryptoListRefresh&&this.isReady&&this.onCryptoListRefresh(this.list.crypto)}catch(t){console.error("Failed fetching currencies list from API",t)}return this}))}runBrowser(){return i(this,void 0,void 0,(function*(){if("undefined"!=typeof window&&window.__ccRunning)throw new Error("The crypto-convert worker seems to be already running. \n\t\t\t- There might be an issue with the way your app imports javascript dependencies. \n\t\t\t- Make sure to call 'convert.stop()' on component unmounts if you are using SPA frameworks (e.g React).");if(!this.isReady){if(yield this.browserTicker(),yield this.browserLists(),!this.isRunning)return!1;!s.isBrowser&&this.options.serverSideCCAPI&&this.options.refreshCryptoList&&(this.lists_worker=setInterval(this.browserLists.bind(this),86400))}return this.crypto_worker=setInterval(this.browserTicker.bind(this),this.options.cryptoInterval),this.isReady=!0,"undefined"!=typeof window&&(window.__ccRunning=!0,window.__ccRunID&&clearInterval(window.__ccRunID),window.__ccRunID=this.crypto_worker),this}))}runServer(){return i(this,void 0,void 0,(function*(){return yield this.updateLists(),yield this.updateFiat(),yield this.updateCrypto(),!!this.isRunning&&(this.isReady=!0,this.crypto_worker=setInterval(this.updateCrypto.bind(this),this.options.cryptoInterval),this.fiat_worker=setInterval(this.updateFiat.bind(this),this.options.fiatInterval),this.options.refreshCryptoList&&(this.lists_worker=setInterval(this.updateLists.bind(this),86400)),this)}))}run(){if(this.isRunning||this.crypto_worker)throw new Error("Crypto-convert is already running.");return this.isRunning=!0,s.isBrowser||this.options.serverSideCCAPI?this.runBrowser():this.runServer()}stop(){return console.log(this.isRunning,this.crypto_worker),this.isRunning=!1,clearInterval(this.crypto_worker),clearInterval(this.fiat_worker),this.crypto_worker=null,this.fiat_worker=null,this.lists_worker&&(clearInterval(this.lists_worker),this.lists_worker=null),"undefined"!=typeof window&&(window.__ccRunning=!1),this}restart(){return this.stop().run()}}},88:t=>{t.exports=__WEBPACK_EXTERNAL_MODULE__88__},265:t=>{t.exports=__WEBPACK_EXTERNAL_MODULE__265__}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var r=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__=__webpack_require__(607);return __webpack_exports__})()));

@@ -236,3 +236,3 @@ "use strict";

v: {
default: '2.0.5'
default: '2.1.0'
},

@@ -249,3 +249,3 @@ filterExchanges: {

list: {
path: "/v2/list?v=2.0.5",
path: "/v2/list?v=2.1.0",
on_success: (response) => (response.json)

@@ -252,0 +252,0 @@ }

@@ -1,3 +0,2 @@

import PricesWorker from './worker';
declare class CustomCurrency {
declare class CustomWorkers {
ticker: {

@@ -11,5 +10,5 @@ [pair: string]: number;

ready(): Promise<any[]>;
addCurrency(base: string, quote: keyof typeof PricesWorker.data.fiat.current, getter: () => number | Promise<number>, interval?: number): Promise<void>;
addCurrency(base: string, quote: string, getter: () => number | Promise<number>, interval?: number): Promise<void>;
removeCurrency(base: string, quote?: string): void;
}
export default CustomCurrency;
export default CustomWorkers;

@@ -11,8 +11,5 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const worker_1 = __importDefault(require("./worker"));
class CustomCurrency {
const worker_1 = require("./worker");
class CustomWorkers {
constructor() {

@@ -32,3 +29,3 @@ this.ticker = {};

return __awaiter(this, void 0, void 0, function* () {
if (typeof base !== "string" || typeof quote !== "string" || !worker_1.default.list.fiat.includes(quote)) {
if (typeof base !== "string" || typeof quote !== "string" || !worker_1.initialCoinList.fiat.includes(quote)) {
throw new Error("Invalid currency pair.");

@@ -77,2 +74,2 @@ }

}
exports.default = CustomCurrency;
exports.default = CustomWorkers;

@@ -16,1 +16,2 @@ export declare function symbolMap(symbol: string, map: {

export declare function isEmpty(obj: any): boolean;
export declare const isBrowser: Document;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isEmpty = exports.formatNumber = exports.getAverage = exports.symbolMap = void 0;
exports.isBrowser = exports.isEmpty = exports.formatNumber = exports.getAverage = exports.symbolMap = void 0;
function symbolMap(symbol, map, recurisve = false) {

@@ -54,1 +54,2 @@ const mapKeys = Object.keys(map);

exports.isEmpty = isEmpty;
exports.isBrowser = (typeof window !== "undefined" && window.document);

@@ -1,18 +0,34 @@

import { Options, PricesClass, Tickers } from "./worker";
/*!
* crypto-convert (c) 2022
* Author: Elis
* License: https://github.com/coinconvert/crypto-convert
*/
import PricesWorker, { Options } from "./worker";
import { Pairs } from './paris';
import CustomCurrency from "./custom";
declare const CustomWorkers: CustomCurrency;
interface Convert extends Pairs {
declare class CryptoConvert {
private worker;
private internalMethods;
private workerReady;
constructor(options?: Options);
/**
* Update options
* Get a symbol price from tickers
*/
setOptions: (options?: Options) => PricesClass;
protected getPrice(coin: string, to?: string): any;
/**
* Price Tickers
* This is where conversion happens.
*/
ticker: Tickers;
private wrapper;
private isSafeKey;
/**
* Recursively creates the conversion wrapper functions for all the currencies.
*/
private populate;
/**
* Quick check if cache has loaded.
*/
get isReady(): boolean;
/**
* Supported currencies list
*/
list: {
get list(): {
crypto: string[];

@@ -24,3 +40,3 @@ fiat: string[];

*/
cryptoInfo: {
get cryptoInfo(): {
[crypto: string]: {

@@ -35,13 +51,22 @@ id: number;

/**
* Quick check if cache has loaded.
* Get crypto prices last updated ms
*/
isReady: boolean;
get lastUpdated(): any;
/**
* Get crypto prices last updated ms
* Price Tickers
*/
lastUpdated: number;
get ticker(): {
crypto: {
last_updated: any;
current: any;
};
fiat: {
last_updated: any;
current: any;
};
};
/**
* Promise function that resolves when cache has loaded.
* Update options
*/
ready: () => Promise<Convert>;
setOptions(options: Options): PricesWorker | Promise<PricesWorker>;
/**

@@ -52,14 +77,12 @@ * Stop the worker.

*/
stop: () => PricesClass;
stop(): PricesWorker;
/**
* Re-start the worker when it has been stopped.
*
* Returns a promise to wait for when it's ready.
*
* ```javascript
* const is_ready = await convert.start();
* ```
*/
start: () => Promise<PricesClass>;
restart(): Promise<false | PricesWorker>;
/**
* Promise function that resolves when cache has loaded.
*/
ready(): Promise<this>;
/**
* Add a custom currency fetcher. Can be anything.

@@ -75,7 +98,7 @@ *

*/
addCurrency: typeof CustomWorkers.addCurrency;
addCurrency(base: string, ...rest: any): Promise<void>;
/**
* Remove custom currency fetcher.
*/
removeCurrency: (base: string, quote?: string) => void;
removeCurrency(base: string, quote?: string): void;
}

@@ -85,2 +108,3 @@ /**

*
* @example
* ```javascript

@@ -94,21 +118,7 @@ * convert.BTC.USD(1);

*
* To check supported currencies:
* ```javascript
* let supportedCurrencies = convert.list;
* ```
* @see {@link https://github.com/coinconvert/crypto-convert Documentation}
*
* To change options:
*
* ```javascript
* convert.setOptions({
* crypto_interval: 5000, //Crypto prices update interval, default every 5 seconds
* fiat_interval: (60 * 1e3 * 60), //Fiat prices update interval, default every 1 hour
* binance: true, //Use binance rates
* bitfinex: true, //Use bitfinex rates
* coinbase: true, //Use coinbase rates
* onUpdate: (tickers, isFiat)=> any //Callback to run on prices update
* });
* ```
*/
declare const convert: Convert;
export default convert;
interface CryptoConvert extends Pairs {
}
export default CryptoConvert;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
/*!
* crypto-convert (c) 2022
* Author: Elis
* License: https://github.com/coinconvert/crypto-convert
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -39,41 +21,39 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

const helpers_1 = require("./helpers");
const worker_1 = __importStar(require("./worker"));
const worker_1 = __importDefault(require("./worker"));
const custom_1 = __importDefault(require("./custom"));
const CustomWorkers = new custom_1.default();
/**
* This is the main object
*/
const ConvertObject = function () {
const convert = {
get isReady() {
return worker_1.default.isReady;
},
get list() {
return {
'crypto': worker_1.default.list.crypto.concat(CustomWorkers.list),
'fiat': worker_1.default.list.fiat
const customWorkers = new custom_1.default();
class CryptoConvert {
constructor(options = {}) {
if (helpers_1.isBrowser) {
if (window['__ccInitialized']) {
throw new Error("You have already initalized one instance of crypto-convert. You cannot initialize multiple instances.");
}
window['__ccInitialized'] = true;
}
this.worker = new worker_1.default(options);
this.workerReady = this.worker.run();
this.internalMethods = Object.keys(this);
Promise.resolve(this.workerReady).then(() => {
this.populate();
this.worker.onCryptoListRefresh = () => {
this.populate();
};
},
get cryptoInfo() {
return worker_1.default.cryptoInfo;
},
get lastUpdated() {
return worker_1.default.data.crypto.last_updated;
},
get ticker() {
return worker_1.default.data;
}
};
//Get symbol price from tickers
const getPrice = function (coin, to = 'USD') {
var customResult = CustomWorkers.ticker[coin + to] || (CustomWorkers.ticker[to + coin] ? 1 / CustomWorkers.ticker[to + coin] : null);
var result = worker_1.default.data.crypto.current[coin + to] || (worker_1.default.data.crypto.current[to + coin] ? 1 / worker_1.default.data.crypto.current[to + coin] : null);
});
}
/**
* Get a symbol price from tickers
*/
getPrice(coin, to = 'USD') {
var customResult = customWorkers.ticker[coin + to] || (customWorkers.ticker[to + coin] ? 1 / customWorkers.ticker[to + coin] : null);
var result = this.worker.data.crypto.current[coin + to] || (this.worker.data.crypto.current[to + coin] ? 1 / this.worker.data.crypto.current[to + coin] : null);
return customResult || result;
};
//Conversion function
const wrapper = function (coin, currency) {
}
/**
* This is where conversion happens.
*/
wrapper(coin, currency) {
var coin = coin;
var toCurrency = currency;
var doExchange = function (fromAmount) {
if ((0, helpers_1.isEmpty)(worker_1.default.data.crypto.current) || (0, helpers_1.isEmpty)(worker_1.default.data.fiat.current)) {
const doExchange = (function (fromAmount) {
if ((0, helpers_1.isEmpty)(this.worker.data.crypto.current) || (0, helpers_1.isEmpty)(this.worker.data.fiat.current)) {
console.warn("[~] Prices are loading.\nYou should use `await convert.ready()` to make sure prices are loaded before calling convert.");

@@ -89,4 +69,4 @@ return false;

}
const fiatCurrencies = worker_1.default.data.fiat.current;
const cryptoCurrenciesList = worker_1.default.list.crypto.concat(CustomWorkers.list);
const fiatCurrencies = this.worker.data.fiat.current;
const cryptoCurrenciesList = this.worker.list.crypto.concat(customWorkers.list);
//Same

@@ -98,4 +78,4 @@ if (toCurrency == coin) {

if (cryptoCurrenciesList.includes(coin) && cryptoCurrenciesList.includes(toCurrency)) {
let exchangePrice = getPrice(coin, toCurrency) ||
wrapper("USD", toCurrency)(wrapper(coin, "USD")(1));
let exchangePrice = this.getPrice(coin, toCurrency) ||
this.wrapper("USD", toCurrency)(this.wrapper(coin, "USD")(1));
return (0, helpers_1.formatNumber)(exchangePrice * fromAmount, 8);

@@ -108,8 +88,8 @@ }

//Crypto->Fiat || Crypto->BTC->Fiat
var getCryptoPrice = function (coin) {
var coinPrice = getPrice(coin) ||
wrapper("BTC", "USD")(getPrice(coin, "BTC")) ||
wrapper("ETH", "USD")(getPrice(coin, "ETH"));
var getCryptoPrice = (function (coin) {
var coinPrice = this.getPrice(coin) ||
this.wrapper("BTC", "USD")(this.getPrice(coin, "BTC")) ||
this.wrapper("ETH", "USD")(this.getPrice(coin, "ETH"));
return coinPrice;
};
}).bind(this);
//Crypto to Fiat

@@ -128,7 +108,15 @@ if (fiatCurrencies[toCurrency]) {

return null;
};
}).bind(this);
return doExchange;
};
//Build pairs object & types
const initialize = function () {
}
isSafeKey(key) {
const functionProto = function () { };
return (!this.internalMethods.includes(key) &&
!key.startsWith('__') &&
!functionProto[key]);
}
/**
* Recursively creates the conversion wrapper functions for all the currencies.
*/
populate() {
let types = '';

@@ -138,10 +126,10 @@ //Generate typescript interface

types += '\nexport interface Pairs {';
const all_currencies = worker_1.default.list.crypto.concat(worker_1.default.list.fiat, CustomWorkers.list);
const all_currencies = this.worker.list.crypto.concat(this.worker.list.fiat, customWorkers.list);
for (var i = 0; i < all_currencies.length; i++) {
var coin = all_currencies[i];
if (!coin || typeof coin !== "string") {
if (!coin || typeof coin !== "string" || !this.isSafeKey(coin)) {
continue;
}
if (!convert[coin]) {
convert[coin] = {};
if (!this[coin]) {
this[coin] = {};
}

@@ -151,6 +139,6 @@ types += `\n\t'${coin.replace(/\'/g, "\\'")}': {`;

var currency = all_currencies[a];
if (!currency || typeof currency !== "string") {
if (!currency || typeof currency !== "string" || !this.isSafeKey(coin)) {
continue;
}
convert[coin][currency] = wrapper(coin, currency);
this[coin][currency] = this.wrapper(coin, currency);
types += `\n\t\t'${currency.replace(/\'/g, "\\'")}': amount,`;

@@ -182,104 +170,127 @@ }

}
};
//These below here are just proxy methods to the worker object.
convert['setOptions'] = function (options) {
let update = worker_1.default.setOptions(options);
if ((options.crypto_interval || options.fiat_interval) && (options.crypto_interval !== worker_1.default.options.crypto_interval ||
options.fiat_interval !== worker_1.default.options.fiat_interval)) {
}
;
/**
* Quick check if cache has loaded.
*/
get isReady() {
return this.worker.isReady;
}
/**
* Supported currencies list
*/
get list() {
return {
'crypto': this.worker.list.crypto.concat(customWorkers.list),
'fiat': this.worker.list.fiat
};
}
/**
* Metadata information about cryptocurrencies
*/
get cryptoInfo() {
return this.worker.cryptoInfo;
}
/**
* Get crypto prices last updated ms
*/
get lastUpdated() {
return this.worker.data.crypto.last_updated;
}
/**
* Price Tickers
*/
get ticker() {
return this.worker.data;
}
/**
* Update options
*/
setOptions(options) {
const workerIntervalChanged = (options.cryptoInterval || options.fiatInterval) && (options.cryptoInterval !== this.worker.options.cryptoInterval ||
options.fiatInterval !== this.worker.options.fiatInterval);
if (workerIntervalChanged ||
(options.hasOwnProperty('refreshCryptoList') && options.refreshCryptoList !== this.worker.options.refreshCryptoList) ||
(options.hasOwnProperty('serverSideCCAPI') && options.serverSideCCAPI !== this.worker.options.serverSideCCAPI)) {
if (!this.worker.isReady) {
throw new Error("You cannot set these options here because CryptoConvert is not ready yet. Instead set the options on the constructor parameter.");
}
//Restart the worker in order to clear interval & update to new interval
let restart = update.restart();
convert['ready'] = function () {
return __awaiter(this, void 0, void 0, function* () {
yield Promise.resolve(restart);
yield Promise.resolve(CustomWorkers.ready());
return convert;
});
};
return restart;
this.workerReady = Promise.resolve(this.worker.setOptions(options))
.then(() => this.worker.restart());
return this.worker;
}
return update;
};
convert['stop'] = function () {
return worker_1.default.stop();
};
convert['start'] = function () {
let restart = worker_1.default.restart();
convert['ready'] = function () {
return __awaiter(this, void 0, void 0, function* () {
yield Promise.resolve(restart);
yield Promise.resolve(CustomWorkers.ready());
return convert;
});
};
return restart;
};
convert['ready'] = function () {
return this.worker.setOptions(options);
}
/**
* Stop the worker.
*
* It's recommended to do this on Component unmounts (i.e if you are using React).
*/
stop() {
return this.worker.stop();
}
/**
* Re-start the worker when it has been stopped.
*/
restart() {
this.workerReady = this.worker.restart();
return this.workerReady;
}
/**
* Promise function that resolves when cache has loaded.
*/
ready() {
return __awaiter(this, void 0, void 0, function* () {
yield Promise.resolve(worker_1.WorkerReady);
yield Promise.resolve(CustomWorkers.ready());
return convert;
yield Promise.resolve(this.workerReady);
yield Promise.resolve(customWorkers.ready());
return this;
});
};
convert['addCurrency'] = (base, ...rest) => {
if (convert.hasOwnProperty(base)) {
throw new Error("This property already exists.");
}
return Promise.resolve(CustomWorkers.addCurrency.apply(CustomWorkers, [base, ...rest])).then(() => {
if (worker_1.default.isReady) {
initialize();
}
/**
* Add a custom currency fetcher. Can be anything.
*
* @example
* ```javascript
* convert.addCurrency('ANY','USD', async fetchPrice()=>{
* //...call your api here
* return price;
* }, 10000);
* ```
*/
addCurrency(base, ...rest) {
return __awaiter(this, void 0, void 0, function* () {
if (this.hasOwnProperty(base)) {
throw new Error("This property already exists.");
}
return Promise.resolve(customWorkers.addCurrency.apply(customWorkers, [base, ...rest])).then(() => {
if (this.worker.isReady) {
this.populate();
}
});
});
};
convert['removeCurrency'] = (base, quote) => {
}
;
/**
* Remove custom currency fetcher.
*/
removeCurrency(base, quote) {
var _a, _b;
if (CustomWorkers.list.includes(base)) {
delete convert[base];
const all_currencies = worker_1.default.list.crypto.concat(worker_1.default.list.fiat, CustomWorkers.list);
if (customWorkers.list.includes(base) && this.isSafeKey(base)) {
delete this[base];
const all_currencies = this.worker.list.crypto.concat(this.worker.list.fiat, customWorkers.list);
for (const currency of all_currencies) {
if ((_a = convert[currency]) === null || _a === void 0 ? void 0 : _a[base]) {
(_b = convert[currency]) === null || _b === void 0 ? true : delete _b[base];
if ((_a = this[currency]) === null || _a === void 0 ? void 0 : _a[base]) {
(_b = this[currency]) === null || _b === void 0 ? true : delete _b[base];
}
}
}
return CustomWorkers.removeCurrency(base, quote);
};
//Wait for updated lists before initializing
Promise.resolve(worker_1.WorkerReady).then(() => (initialize()));
return convert;
}();
/**
* Convert crypto to fiat and vice-versa.
*
* ```javascript
* convert.BTC.USD(1);
* convert.USD.BTC(1);
* convert.BTC.ETH(1);
* convert.ETH.JPY(1);
* convert.USD.EUR(1);
* ```
*
* To check supported currencies:
* ```javascript
* let supportedCurrencies = convert.list;
* ```
*
* To change options:
*
* ```javascript
* convert.setOptions({
* crypto_interval: 5000, //Crypto prices update interval, default every 5 seconds
* fiat_interval: (60 * 1e3 * 60), //Fiat prices update interval, default every 1 hour
* binance: true, //Use binance rates
* bitfinex: true, //Use bitfinex rates
* coinbase: true, //Use coinbase rates
* onUpdate: (tickers, isFiat)=> any //Callback to run on prices update
* });
* ```
*/
const convert = ConvertObject;
return customWorkers.removeCurrency(base, quote);
}
}
//@ts-ignore
convert.default = convert;
CryptoConvert.default = CryptoConvert;
if (typeof module !== "undefined" && module.exports) {
module.exports = convert;
module.exports = CryptoConvert;
}
exports.default = convert;
exports.default = CryptoConvert;

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

/// <reference types="node" />
export interface Options {

@@ -5,7 +6,7 @@ /**

*/
crypto_interval?: number;
cryptoInterval?: number;
/**
* Fiat prices update interval in ms (Default: 1 hour)
*/
fiat_interval?: number;
fiatInterval?: number;
/**

@@ -35,2 +36,14 @@ * Calculate Average prices from multiple exchanges (Default: true)

onUpdate?: (tickers: any, isFiat?: boolean) => any;
/**
* Use the hosted version of the API on server-side as well.
*/
serverSideCCAPI?: boolean;
/**
* Refresh crypto list (server-side only)
*/
refreshCryptoList?: boolean;
/**
* HTTP agent for server-side proxies
*/
HTTPAgent?: any;
}

@@ -95,4 +108,8 @@ export interface Tickers {

}
export interface PricesClass {
data: Tickers;
export declare const initialCoinList: {
crypto: string[];
fiat: string[];
};
declare class PricesWorker {
exchanges: string[];
list: {

@@ -102,12 +119,2 @@ crypto: string[];

};
setOptions: (options: Options | ((currentOptions: Options) => Options)) => PricesClass;
stop: () => PricesClass;
restart: () => Promise<PricesClass>;
run: () => Promise<PricesClass>;
options: Options;
isRunning: boolean;
isReady: boolean;
/**
* Metadata information about cryptocurrencies
*/
cryptoInfo: {

@@ -122,5 +129,37 @@ [crypto: string]: {

};
data: {
crypto: {
last_updated: any;
current: any;
};
fiat: {
last_updated: any;
current: any;
};
};
options: Options;
log(..._: any): void;
isReady: boolean;
isRunning: boolean;
fiat_worker: NodeJS.Timer;
crypto_worker: NodeJS.Timer;
lists_worker: NodeJS.Timer;
onCryptoListRefresh: (list: any) => any;
constructor(options?: Options);
/**
* Options
*/
setOptions(o?: Options | ((currentOptions: Options) => Options)): this | Promise<this>;
updateCrypto(): Promise<this>;
updateFiat(): Promise<this>;
updateLists(): Promise<this>;
joinPrices(data: Tickers): {};
browserTicker(): Promise<this>;
browserLists(): Promise<this>;
runBrowser(): Promise<false | this>;
runServer(): Promise<false | this>;
run(): Promise<false | this>;
stop(): this;
restart(): Promise<false | this>;
}
declare const PricesWorker: PricesClass;
export declare const WorkerReady: Promise<PricesClass>;
export default PricesWorker;

@@ -15,35 +15,47 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.WorkerReady = void 0;
exports.initialCoinList = void 0;
const api_1 = __importDefault(require("./api"));
const helpers_1 = require("./helpers");
const isBrowser = (typeof window !== "undefined" && window.document);
function Prices(initialOptions = {}) {
this.exchanges = ['binance', 'bitfinex', 'coinbase', 'kraken'];
this.list = {
"crypto": [
"BTC", "ETH", "USDT", "USDC", "BNB", "XRP", "BUSD", "ADA", "SOL", "DOGE", "DOT", "DAI", "MATIC", "SHIB", "TRX", "AVAX", "UNI", "WBTC", "LEO", "LTC", "ETC", "LINK", "ATOM", "FTT", "XLM", "NEAR", "CRO", "XMR", "ALGO", "BCH", "LUNC", "FLOW", "QNT", "VET", "TON", "FIL", "APE", "ICP", "CHZ", "HBAR", "MANA", "XTZ", "SAND", "EOS", "EGLD", "THETA", "AAVE", "AXS", "OKB", "USDP", "BSV", "KCS", "TUSD", "ZEC", "MIOTA", "XEC", "USDD", "MKR", "BTT", "HT", "GRT", "USDN", "HNT", "CAKE", "NEO", "KLAY", "FTM", "SNX", "PAXG", "RUNE", "NEXO", "LDO", "CRV", "GT", "DASH", "ENJ", "BAT", "COMP", "STX", "KAVA", "RVN", "ZIL", "WAVES", "FEI", "MINA", "RSR", "XDC", "LRC", "GMT", "DCR", "TWT", "CELO", "XEM", "BTG", "KSM", "HOT", "1INCH", "CEL", "CVX", "BNX", "AR", "GNO", "LUNA", "ROSE", "ENS", "USTC", "GUSD", "QTUM", "YFI", "ANKR", "TFUEL", "GALA", "GLM", "IOTX", "KDA", "BTRST", "ONE", "OMG", "BAL", "ZRX", "LPT", "POLY", "JST", "FLUX", "ICX", "BORA", "IOST", "HIVE", "AMP", "OP", "KNC", "XYM", "SRM", "ONT", "WAXP", "STORJ", "MXC", "CSPR", "IMX", "SC", "ZEN", "AUDIO", "GLMR", "SXP", "XCH", "ABBC", "CHSB", "VGX", "UMA", "WOO"
],
"fiat": [
"USD", "JPY", "BGN", "CZK", "DKK", "GBP", "HUF", "PLN", "RON", "SEK", "CHF", "ISK", "NOK", "HRK", "RUB", "TRY", "AUD", "BRL", "CAD", "CNY", "HKD", "IDR", "ILS", "INR", "KRW", "MXN", "MYR", "NZD", "PHP", "SGD", "THB", "ZAR", "EUR"
]
};
this.cryptoInfo = [{ "id": 1, "title": "Bitcoin", "symbol": "BTC", "rank": 1 }, { "id": 1027, "title": "Ethereum", "symbol": "ETH", "rank": 2 }, { "id": 825, "title": "Tether", "symbol": "USDT", "rank": 3 }, { "id": 3408, "title": "USD Coin", "symbol": "USDC", "rank": 4 }, { "id": 1839, "title": "BNB", "symbol": "BNB", "rank": 5 }, { "id": 52, "title": "XRP", "symbol": "XRP", "rank": 6 }, { "id": 4687, "title": "Binance USD", "symbol": "BUSD", "rank": 7 }, { "id": 2010, "title": "Cardano", "symbol": "ADA", "rank": 8 }, { "id": 5426, "title": "Solana", "symbol": "SOL", "rank": 9 }, { "id": 74, "title": "Dogecoin", "symbol": "DOGE", "rank": 10 }, { "id": 6636, "title": "Polkadot", "symbol": "DOT", "rank": 11 }, { "id": 4943, "title": "Dai", "symbol": "DAI", "rank": 12 }, { "id": 3890, "title": "Polygon", "symbol": "MATIC", "rank": 13 }, { "id": 5994, "title": "Shiba Inu", "symbol": "SHIB", "rank": 14 }, { "id": 1958, "title": "TRON", "symbol": "TRX", "rank": 15 }, { "id": 5805, "title": "Avalanche", "symbol": "AVAX", "rank": 16 }, { "id": 7083, "title": "Uniswap", "symbol": "UNI", "rank": 17 }, { "id": 3717, "title": "Wrapped Bitcoin", "symbol": "WBTC", "rank": 18 }, { "id": 3957, "title": "UNUS SED LEO", "symbol": "LEO", "rank": 19 }, { "id": 2, "title": "Litecoin", "symbol": "LTC", "rank": 20 }, { "id": 1321, "title": "Ethereum Classic", "symbol": "ETC", "rank": 21 }, { "id": 1975, "title": "Chainlink", "symbol": "LINK", "rank": 22 }, { "id": 3794, "title": "Cosmos", "symbol": "ATOM", "rank": 23 }, { "id": 4195, "title": "FTX Token", "symbol": "FTT", "rank": 24 }, { "id": 512, "title": "Stellar", "symbol": "XLM", "rank": 25 }, { "id": 6535, "title": "NEAR Protocol", "symbol": "NEAR", "rank": 26 }, { "id": 3635, "title": "Cronos", "symbol": "CRO", "rank": 27 }, { "id": 328, "title": "Monero", "symbol": "XMR", "rank": 28 }, { "id": 4030, "title": "Algorand", "symbol": "ALGO", "rank": 29 }, { "id": 1831, "title": "Bitcoin Cash", "symbol": "BCH", "rank": 30 }, { "id": 4172, "title": "Terra Classic", "symbol": "LUNC", "rank": 31 }, { "id": 4558, "title": "Flow", "symbol": "FLOW", "rank": 32 }, { "id": 3155, "title": "Quant", "symbol": "QNT", "rank": 33 }, { "id": 3077, "title": "VeChain", "symbol": "VET", "rank": 34 }, { "id": 11419, "title": "Toncoin", "symbol": "TON", "rank": 35 }, { "id": 2280, "title": "Filecoin", "symbol": "FIL", "rank": 36 }, { "id": 18876, "title": "ApeCoin", "symbol": "APE", "rank": 37 }, { "id": 8916, "title": "Internet Computer", "symbol": "ICP", "rank": 38 }, { "id": 4066, "title": "Chiliz", "symbol": "CHZ", "rank": 39 }, { "id": 4642, "title": "Hedera", "symbol": "HBAR", "rank": 40 }, { "id": 1966, "title": "Decentraland", "symbol": "MANA", "rank": 41 }, { "id": 2011, "title": "Tezos", "symbol": "XTZ", "rank": 42 }, { "id": 6210, "title": "The Sandbox", "symbol": "SAND", "rank": 43 }, { "id": 1765, "title": "EOS", "symbol": "EOS", "rank": 44 }, { "id": 6892, "title": "Elrond", "symbol": "EGLD", "rank": 45 }, { "id": 2416, "title": "Theta Network", "symbol": "THETA", "rank": 46 }, { "id": 7278, "title": "Aave", "symbol": "AAVE", "rank": 47 }, { "id": 6783, "title": "Axie Infinity", "symbol": "AXS", "rank": 48 }, { "id": 3897, "title": "OKB", "symbol": "OKB", "rank": 49 }, { "id": 3330, "title": "Pax Dollar", "symbol": "USDP", "rank": 50 }, { "id": 3602, "title": "Bitcoin SV", "symbol": "BSV", "rank": 51 }, { "id": 2087, "title": "KuCoin Token", "symbol": "KCS", "rank": 52 }, { "id": 2563, "title": "TrueUSD", "symbol": "TUSD", "rank": 53 }, { "id": 1437, "title": "Zcash", "symbol": "ZEC", "rank": 54 }, { "id": 1720, "title": "IOTA", "symbol": "MIOTA", "rank": 55 }, { "id": 10791, "title": "eCash", "symbol": "XEC", "rank": 56 }, { "id": 19891, "title": "USDD", "symbol": "USDD", "rank": 57 }, { "id": 1518, "title": "Maker", "symbol": "MKR", "rank": 58 }, { "id": 16086, "title": "BitTorrent-New", "symbol": "BTT", "rank": 59 }, { "id": 2502, "title": "Huobi Token", "symbol": "HT", "rank": 60 }, { "id": 6719, "title": "The Graph", "symbol": "GRT", "rank": 61 }, { "id": 5068, "title": "Neutrino USD", "symbol": "USDN", "rank": 62 }, { "id": 5665, "title": "Helium", "symbol": "HNT", "rank": 63 }, { "id": 7186, "title": "PancakeSwap", "symbol": "CAKE", "rank": 64 }, { "id": 1376, "title": "Neo", "symbol": "NEO", "rank": 65 }, { "id": 4256, "title": "Klaytn", "symbol": "KLAY", "rank": 66 }, { "id": 3513, "title": "Fantom", "symbol": "FTM", "rank": 67 }, { "id": 2586, "title": "Synthetix", "symbol": "SNX", "rank": 68 }, { "id": 4705, "title": "PAX Gold", "symbol": "PAXG", "rank": 69 }, { "id": 4157, "title": "THORChain", "symbol": "RUNE", "rank": 70 }, { "id": 2694, "title": "Nexo", "symbol": "NEXO", "rank": 71 }, { "id": 8000, "title": "Lido DAO", "symbol": "LDO", "rank": 72 }, { "id": 6538, "title": "Curve DAO Token", "symbol": "CRV", "rank": 73 }, { "id": 4269, "title": "GateToken", "symbol": "GT", "rank": 74 }, { "id": 131, "title": "Dash", "symbol": "DASH", "rank": 75 }, { "id": 2130, "title": "Enjin Coin", "symbol": "ENJ", "rank": 76 }, { "id": 1697, "title": "Basic Attention Token", "symbol": "BAT", "rank": 77 }, { "id": 5692, "title": "Compound", "symbol": "COMP", "rank": 78 }, { "id": 4847, "title": "Stacks", "symbol": "STX", "rank": 79 }, { "id": 4846, "title": "Kava", "symbol": "KAVA", "rank": 80 }, { "id": 2577, "title": "Ravencoin", "symbol": "RVN", "rank": 81 }, { "id": 2469, "title": "Zilliqa", "symbol": "ZIL", "rank": 82 }, { "id": 1274, "title": "Waves", "symbol": "WAVES", "rank": 83 }, { "id": 8642, "title": "Fei USD", "symbol": "FEI", "rank": 84 }, { "id": 8646, "title": "Mina", "symbol": "MINA", "rank": 85 }, { "id": 3964, "title": "Reserve Rights", "symbol": "RSR", "rank": 86 }, { "id": 2634, "title": "XDC Network", "symbol": "XDC", "rank": 87 }, { "id": 1934, "title": "Loopring", "symbol": "LRC", "rank": 88 }, { "id": 18069, "title": "STEPN", "symbol": "GMT", "rank": 89 }, { "id": 1168, "title": "Decred", "symbol": "DCR", "rank": 90 }, { "id": 5964, "title": "Trust Wallet Token", "symbol": "TWT", "rank": 91 }, { "id": 5567, "title": "Celo", "symbol": "CELO", "rank": 92 }, { "id": 873, "title": "NEM", "symbol": "XEM", "rank": 93 }, { "id": 2083, "title": "Bitcoin Gold", "symbol": "BTG", "rank": 94 }, { "id": 5034, "title": "Kusama", "symbol": "KSM", "rank": 95 }, { "id": 2682, "title": "Holo", "symbol": "HOT", "rank": 96 }, { "id": 8104, "title": "1inch Network", "symbol": "1INCH", "rank": 97 }, { "id": 2700, "title": "Celsius", "symbol": "CEL", "rank": 98 }, { "id": 9903, "title": "Convex Finance", "symbol": "CVX", "rank": 99 }, { "id": 9891, "title": "BinaryX", "symbol": "BNX", "rank": 100 }, { "id": 5632, "title": "Arweave", "symbol": "AR", "rank": 101 }, { "id": 1659, "title": "Gnosis", "symbol": "GNO", "rank": 102 }, { "id": 20314, "title": "Terra", "symbol": "LUNA", "rank": 103 }, { "id": 7653, "title": "Oasis Network", "symbol": "ROSE", "rank": 104 }, { "id": 13855, "title": "Ethereum Name Service", "symbol": "ENS", "rank": 105 }, { "id": 7129, "title": "TerraClassicUSD", "symbol": "USTC", "rank": 106 }, { "id": 3306, "title": "Gemini Dollar", "symbol": "GUSD", "rank": 107 }, { "id": 1684, "title": "Qtum", "symbol": "QTUM", "rank": 108 }, { "id": 5864, "title": "yearn.finance", "symbol": "YFI", "rank": 109 }, { "id": 3783, "title": "Ankr", "symbol": "ANKR", "rank": 110 }, { "id": 3822, "title": "Theta Fuel", "symbol": "TFUEL", "rank": 111 }, { "id": 7080, "title": "Gala", "symbol": "GALA", "rank": 112 }, { "id": 1455, "title": "Golem", "symbol": "GLM", "rank": 113 }, { "id": 2777, "title": "IoTeX", "symbol": "IOTX", "rank": 114 }, { "id": 5647, "title": "Kadena", "symbol": "KDA", "rank": 115 }, { "id": 11584, "title": "Braintrust", "symbol": "BTRST", "rank": 116 }, { "id": 3945, "title": "Harmony", "symbol": "ONE", "rank": 117 }, { "id": 1808, "title": "OMG Network", "symbol": "OMG", "rank": 118 }, { "id": 5728, "title": "Balancer", "symbol": "BAL", "rank": 119 }, { "id": 1896, "title": "0x", "symbol": "ZRX", "rank": 120 }, { "id": 3640, "title": "Livepeer", "symbol": "LPT", "rank": 121 }, { "id": 2496, "title": "Polymath", "symbol": "POLY", "rank": 122 }, { "id": 5488, "title": "JUST", "symbol": "JST", "rank": 123 }, { "id": 3029, "title": "Flux", "symbol": "FLUX", "rank": 124 }, { "id": 2099, "title": "ICON", "symbol": "ICX", "rank": 125 }, { "id": 3801, "title": "BORA", "symbol": "BORA", "rank": 126 }, { "id": 2405, "title": "IOST", "symbol": "IOST", "rank": 127 }, { "id": 5370, "title": "Hive", "symbol": "HIVE", "rank": 128 }, { "id": 6945, "title": "Amp", "symbol": "AMP", "rank": 129 }, { "id": 11840, "title": "Optimism", "symbol": "OP", "rank": 130 }, { "id": 9444, "title": "Kyber Network Crystal v2", "symbol": "KNC", "rank": 131 }, { "id": 8677, "title": "Symbol", "symbol": "XYM", "rank": 132 }, { "id": 6187, "title": "Serum", "symbol": "SRM", "rank": 133 }, { "id": 2566, "title": "Ontology", "symbol": "ONT", "rank": 134 }, { "id": 2300, "title": "WAX", "symbol": "WAXP", "rank": 135 }, { "id": 1772, "title": "Storj", "symbol": "STORJ", "rank": 136 }, { "id": 3628, "title": "MXC", "symbol": "MXC", "rank": 137 }, { "id": 5899, "title": "Casper", "symbol": "CSPR", "rank": 138 }, { "id": 10603, "title": "Immutable X", "symbol": "IMX", "rank": 139 }, { "id": 1042, "title": "Siacoin", "symbol": "SC", "rank": 140 }, { "id": 1698, "title": "Horizen", "symbol": "ZEN", "rank": 141 }, { "id": 7455, "title": "Audius", "symbol": "AUDIO", "rank": 142 }, { "id": 6836, "title": "Moonbeam", "symbol": "GLMR", "rank": 143 }, { "id": 4279, "title": "SXP", "symbol": "SXP", "rank": 144 }, { "id": 9258, "title": "Chia", "symbol": "XCH", "rank": 145 }, { "id": 3437, "title": "ABBC Coin", "symbol": "ABBC", "rank": 146 }, { "id": 2499, "title": "SwissBorg", "symbol": "CHSB", "rank": 147 }, { "id": 1817, "title": "Voyager Token", "symbol": "VGX", "rank": 148 }, { "id": 5617, "title": "UMA", "symbol": "UMA", "rank": 149 }, { "id": 7501, "title": "WOO Network", "symbol": "WOO", "rank": 150 }]
.reduce((o, v) => {
o[v.symbol] = Object.assign(Object.assign({}, o), { logo: `https://s2.coinmarketcap.com/static/img/coins/128x128/${v.id}.png` });
return o;
}, {});
this.data = {
"crypto": {
last_updated: null,
current: null
},
"fiat": {
last_updated: null,
current: null
exports.initialCoinList = {
"crypto": [
"BTC", "ETH", "USDT", "USDC", "BNB", "XRP", "BUSD", "ADA", "SOL", "DOGE", "DOT", "DAI", "MATIC", "SHIB", "TRX", "AVAX", "UNI", "WBTC", "LEO", "LTC", "ETC", "LINK", "ATOM", "FTT", "XLM", "NEAR", "CRO", "XMR", "ALGO", "BCH", "LUNC", "FLOW", "QNT", "VET", "TON", "FIL", "APE", "ICP", "CHZ", "HBAR", "MANA", "XTZ", "SAND", "EOS", "EGLD", "THETA", "AAVE", "AXS", "OKB", "USDP", "BSV", "KCS", "TUSD", "ZEC", "MIOTA", "XEC", "USDD", "MKR", "BTT", "HT", "GRT", "USDN", "HNT", "CAKE", "NEO", "KLAY", "FTM", "SNX", "PAXG", "RUNE", "NEXO", "LDO", "CRV", "GT", "DASH", "ENJ", "BAT", "COMP", "STX", "KAVA", "RVN", "ZIL", "WAVES", "FEI", "MINA", "RSR", "XDC", "LRC", "GMT", "DCR", "TWT", "CELO", "XEM", "BTG", "KSM", "HOT", "1INCH", "CEL", "CVX", "BNX", "AR", "GNO", "LUNA", "ROSE", "ENS", "USTC", "GUSD", "QTUM", "YFI", "ANKR", "TFUEL", "GALA", "GLM", "IOTX", "KDA", "BTRST", "ONE", "OMG", "BAL", "ZRX", "LPT", "POLY", "JST", "FLUX", "ICX", "BORA", "IOST", "HIVE", "AMP", "OP", "KNC", "XYM", "SRM", "ONT", "WAXP", "STORJ", "MXC", "CSPR", "IMX", "SC", "ZEN", "AUDIO", "GLMR", "SXP", "XCH", "ABBC", "CHSB", "VGX", "UMA", "WOO"
],
"fiat": [
"USD", "JPY", "BGN", "CZK", "DKK", "GBP", "HUF", "PLN", "RON", "SEK", "CHF", "ISK", "NOK", "HRK", "RUB", "TRY", "AUD", "BRL", "CAD", "CNY", "HKD", "IDR", "ILS", "INR", "KRW", "MXN", "MYR", "NZD", "PHP", "SGD", "THB", "ZAR", "EUR"
]
};
class PricesWorker {
constructor(options = {}) {
this.exchanges = ['binance', 'bitfinex', 'coinbase', 'kraken'];
this.list = exports.initialCoinList;
this.cryptoInfo = [{ "id": 1, "title": "Bitcoin", "symbol": "BTC", "rank": 1 }, { "id": 1027, "title": "Ethereum", "symbol": "ETH", "rank": 2 }, { "id": 825, "title": "Tether", "symbol": "USDT", "rank": 3 }, { "id": 3408, "title": "USD Coin", "symbol": "USDC", "rank": 4 }, { "id": 1839, "title": "BNB", "symbol": "BNB", "rank": 5 }, { "id": 52, "title": "XRP", "symbol": "XRP", "rank": 6 }, { "id": 4687, "title": "Binance USD", "symbol": "BUSD", "rank": 7 }, { "id": 2010, "title": "Cardano", "symbol": "ADA", "rank": 8 }, { "id": 5426, "title": "Solana", "symbol": "SOL", "rank": 9 }, { "id": 74, "title": "Dogecoin", "symbol": "DOGE", "rank": 10 }, { "id": 6636, "title": "Polkadot", "symbol": "DOT", "rank": 11 }, { "id": 4943, "title": "Dai", "symbol": "DAI", "rank": 12 }, { "id": 3890, "title": "Polygon", "symbol": "MATIC", "rank": 13 }, { "id": 5994, "title": "Shiba Inu", "symbol": "SHIB", "rank": 14 }, { "id": 1958, "title": "TRON", "symbol": "TRX", "rank": 15 }, { "id": 5805, "title": "Avalanche", "symbol": "AVAX", "rank": 16 }, { "id": 7083, "title": "Uniswap", "symbol": "UNI", "rank": 17 }, { "id": 3717, "title": "Wrapped Bitcoin", "symbol": "WBTC", "rank": 18 }, { "id": 3957, "title": "UNUS SED LEO", "symbol": "LEO", "rank": 19 }, { "id": 2, "title": "Litecoin", "symbol": "LTC", "rank": 20 }, { "id": 1321, "title": "Ethereum Classic", "symbol": "ETC", "rank": 21 }, { "id": 1975, "title": "Chainlink", "symbol": "LINK", "rank": 22 }, { "id": 3794, "title": "Cosmos", "symbol": "ATOM", "rank": 23 }, { "id": 4195, "title": "FTX Token", "symbol": "FTT", "rank": 24 }, { "id": 512, "title": "Stellar", "symbol": "XLM", "rank": 25 }, { "id": 6535, "title": "NEAR Protocol", "symbol": "NEAR", "rank": 26 }, { "id": 3635, "title": "Cronos", "symbol": "CRO", "rank": 27 }, { "id": 328, "title": "Monero", "symbol": "XMR", "rank": 28 }, { "id": 4030, "title": "Algorand", "symbol": "ALGO", "rank": 29 }, { "id": 1831, "title": "Bitcoin Cash", "symbol": "BCH", "rank": 30 }, { "id": 4172, "title": "Terra Classic", "symbol": "LUNC", "rank": 31 }, { "id": 4558, "title": "Flow", "symbol": "FLOW", "rank": 32 }, { "id": 3155, "title": "Quant", "symbol": "QNT", "rank": 33 }, { "id": 3077, "title": "VeChain", "symbol": "VET", "rank": 34 }, { "id": 11419, "title": "Toncoin", "symbol": "TON", "rank": 35 }, { "id": 2280, "title": "Filecoin", "symbol": "FIL", "rank": 36 }, { "id": 18876, "title": "ApeCoin", "symbol": "APE", "rank": 37 }, { "id": 8916, "title": "Internet Computer", "symbol": "ICP", "rank": 38 }, { "id": 4066, "title": "Chiliz", "symbol": "CHZ", "rank": 39 }, { "id": 4642, "title": "Hedera", "symbol": "HBAR", "rank": 40 }, { "id": 1966, "title": "Decentraland", "symbol": "MANA", "rank": 41 }, { "id": 2011, "title": "Tezos", "symbol": "XTZ", "rank": 42 }, { "id": 6210, "title": "The Sandbox", "symbol": "SAND", "rank": 43 }, { "id": 1765, "title": "EOS", "symbol": "EOS", "rank": 44 }, { "id": 6892, "title": "Elrond", "symbol": "EGLD", "rank": 45 }, { "id": 2416, "title": "Theta Network", "symbol": "THETA", "rank": 46 }, { "id": 7278, "title": "Aave", "symbol": "AAVE", "rank": 47 }, { "id": 6783, "title": "Axie Infinity", "symbol": "AXS", "rank": 48 }, { "id": 3897, "title": "OKB", "symbol": "OKB", "rank": 49 }, { "id": 3330, "title": "Pax Dollar", "symbol": "USDP", "rank": 50 }, { "id": 3602, "title": "Bitcoin SV", "symbol": "BSV", "rank": 51 }, { "id": 2087, "title": "KuCoin Token", "symbol": "KCS", "rank": 52 }, { "id": 2563, "title": "TrueUSD", "symbol": "TUSD", "rank": 53 }, { "id": 1437, "title": "Zcash", "symbol": "ZEC", "rank": 54 }, { "id": 1720, "title": "IOTA", "symbol": "MIOTA", "rank": 55 }, { "id": 10791, "title": "eCash", "symbol": "XEC", "rank": 56 }, { "id": 19891, "title": "USDD", "symbol": "USDD", "rank": 57 }, { "id": 1518, "title": "Maker", "symbol": "MKR", "rank": 58 }, { "id": 16086, "title": "BitTorrent-New", "symbol": "BTT", "rank": 59 }, { "id": 2502, "title": "Huobi Token", "symbol": "HT", "rank": 60 }, { "id": 6719, "title": "The Graph", "symbol": "GRT", "rank": 61 }, { "id": 5068, "title": "Neutrino USD", "symbol": "USDN", "rank": 62 }, { "id": 5665, "title": "Helium", "symbol": "HNT", "rank": 63 }, { "id": 7186, "title": "PancakeSwap", "symbol": "CAKE", "rank": 64 }, { "id": 1376, "title": "Neo", "symbol": "NEO", "rank": 65 }, { "id": 4256, "title": "Klaytn", "symbol": "KLAY", "rank": 66 }, { "id": 3513, "title": "Fantom", "symbol": "FTM", "rank": 67 }, { "id": 2586, "title": "Synthetix", "symbol": "SNX", "rank": 68 }, { "id": 4705, "title": "PAX Gold", "symbol": "PAXG", "rank": 69 }, { "id": 4157, "title": "THORChain", "symbol": "RUNE", "rank": 70 }, { "id": 2694, "title": "Nexo", "symbol": "NEXO", "rank": 71 }, { "id": 8000, "title": "Lido DAO", "symbol": "LDO", "rank": 72 }, { "id": 6538, "title": "Curve DAO Token", "symbol": "CRV", "rank": 73 }, { "id": 4269, "title": "GateToken", "symbol": "GT", "rank": 74 }, { "id": 131, "title": "Dash", "symbol": "DASH", "rank": 75 }, { "id": 2130, "title": "Enjin Coin", "symbol": "ENJ", "rank": 76 }, { "id": 1697, "title": "Basic Attention Token", "symbol": "BAT", "rank": 77 }, { "id": 5692, "title": "Compound", "symbol": "COMP", "rank": 78 }, { "id": 4847, "title": "Stacks", "symbol": "STX", "rank": 79 }, { "id": 4846, "title": "Kava", "symbol": "KAVA", "rank": 80 }, { "id": 2577, "title": "Ravencoin", "symbol": "RVN", "rank": 81 }, { "id": 2469, "title": "Zilliqa", "symbol": "ZIL", "rank": 82 }, { "id": 1274, "title": "Waves", "symbol": "WAVES", "rank": 83 }, { "id": 8642, "title": "Fei USD", "symbol": "FEI", "rank": 84 }, { "id": 8646, "title": "Mina", "symbol": "MINA", "rank": 85 }, { "id": 3964, "title": "Reserve Rights", "symbol": "RSR", "rank": 86 }, { "id": 2634, "title": "XDC Network", "symbol": "XDC", "rank": 87 }, { "id": 1934, "title": "Loopring", "symbol": "LRC", "rank": 88 }, { "id": 18069, "title": "STEPN", "symbol": "GMT", "rank": 89 }, { "id": 1168, "title": "Decred", "symbol": "DCR", "rank": 90 }, { "id": 5964, "title": "Trust Wallet Token", "symbol": "TWT", "rank": 91 }, { "id": 5567, "title": "Celo", "symbol": "CELO", "rank": 92 }, { "id": 873, "title": "NEM", "symbol": "XEM", "rank": 93 }, { "id": 2083, "title": "Bitcoin Gold", "symbol": "BTG", "rank": 94 }, { "id": 5034, "title": "Kusama", "symbol": "KSM", "rank": 95 }, { "id": 2682, "title": "Holo", "symbol": "HOT", "rank": 96 }, { "id": 8104, "title": "1inch Network", "symbol": "1INCH", "rank": 97 }, { "id": 2700, "title": "Celsius", "symbol": "CEL", "rank": 98 }, { "id": 9903, "title": "Convex Finance", "symbol": "CVX", "rank": 99 }, { "id": 9891, "title": "BinaryX", "symbol": "BNX", "rank": 100 }, { "id": 5632, "title": "Arweave", "symbol": "AR", "rank": 101 }, { "id": 1659, "title": "Gnosis", "symbol": "GNO", "rank": 102 }, { "id": 20314, "title": "Terra", "symbol": "LUNA", "rank": 103 }, { "id": 7653, "title": "Oasis Network", "symbol": "ROSE", "rank": 104 }, { "id": 13855, "title": "Ethereum Name Service", "symbol": "ENS", "rank": 105 }, { "id": 7129, "title": "TerraClassicUSD", "symbol": "USTC", "rank": 106 }, { "id": 3306, "title": "Gemini Dollar", "symbol": "GUSD", "rank": 107 }, { "id": 1684, "title": "Qtum", "symbol": "QTUM", "rank": 108 }, { "id": 5864, "title": "yearn.finance", "symbol": "YFI", "rank": 109 }, { "id": 3783, "title": "Ankr", "symbol": "ANKR", "rank": 110 }, { "id": 3822, "title": "Theta Fuel", "symbol": "TFUEL", "rank": 111 }, { "id": 7080, "title": "Gala", "symbol": "GALA", "rank": 112 }, { "id": 1455, "title": "Golem", "symbol": "GLM", "rank": 113 }, { "id": 2777, "title": "IoTeX", "symbol": "IOTX", "rank": 114 }, { "id": 5647, "title": "Kadena", "symbol": "KDA", "rank": 115 }, { "id": 11584, "title": "Braintrust", "symbol": "BTRST", "rank": 116 }, { "id": 3945, "title": "Harmony", "symbol": "ONE", "rank": 117 }, { "id": 1808, "title": "OMG Network", "symbol": "OMG", "rank": 118 }, { "id": 5728, "title": "Balancer", "symbol": "BAL", "rank": 119 }, { "id": 1896, "title": "0x", "symbol": "ZRX", "rank": 120 }, { "id": 3640, "title": "Livepeer", "symbol": "LPT", "rank": 121 }, { "id": 2496, "title": "Polymath", "symbol": "POLY", "rank": 122 }, { "id": 5488, "title": "JUST", "symbol": "JST", "rank": 123 }, { "id": 3029, "title": "Flux", "symbol": "FLUX", "rank": 124 }, { "id": 2099, "title": "ICON", "symbol": "ICX", "rank": 125 }, { "id": 3801, "title": "BORA", "symbol": "BORA", "rank": 126 }, { "id": 2405, "title": "IOST", "symbol": "IOST", "rank": 127 }, { "id": 5370, "title": "Hive", "symbol": "HIVE", "rank": 128 }, { "id": 6945, "title": "Amp", "symbol": "AMP", "rank": 129 }, { "id": 11840, "title": "Optimism", "symbol": "OP", "rank": 130 }, { "id": 9444, "title": "Kyber Network Crystal v2", "symbol": "KNC", "rank": 131 }, { "id": 8677, "title": "Symbol", "symbol": "XYM", "rank": 132 }, { "id": 6187, "title": "Serum", "symbol": "SRM", "rank": 133 }, { "id": 2566, "title": "Ontology", "symbol": "ONT", "rank": 134 }, { "id": 2300, "title": "WAX", "symbol": "WAXP", "rank": 135 }, { "id": 1772, "title": "Storj", "symbol": "STORJ", "rank": 136 }, { "id": 3628, "title": "MXC", "symbol": "MXC", "rank": 137 }, { "id": 5899, "title": "Casper", "symbol": "CSPR", "rank": 138 }, { "id": 10603, "title": "Immutable X", "symbol": "IMX", "rank": 139 }, { "id": 1042, "title": "Siacoin", "symbol": "SC", "rank": 140 }, { "id": 1698, "title": "Horizen", "symbol": "ZEN", "rank": 141 }, { "id": 7455, "title": "Audius", "symbol": "AUDIO", "rank": 142 }, { "id": 6836, "title": "Moonbeam", "symbol": "GLMR", "rank": 143 }, { "id": 4279, "title": "SXP", "symbol": "SXP", "rank": 144 }, { "id": 9258, "title": "Chia", "symbol": "XCH", "rank": 145 }, { "id": 3437, "title": "ABBC Coin", "symbol": "ABBC", "rank": 146 }, { "id": 2499, "title": "SwissBorg", "symbol": "CHSB", "rank": 147 }, { "id": 1817, "title": "Voyager Token", "symbol": "VGX", "rank": 148 }, { "id": 5617, "title": "UMA", "symbol": "UMA", "rank": 149 }, { "id": 7501, "title": "WOO Network", "symbol": "WOO", "rank": 150 }]
.reduce((o, v) => {
o[v.symbol] = Object.assign(Object.assign({}, o), { logo: `https://s2.coinmarketcap.com/static/img/coins/128x128/${v.id}.png` });
return o;
}, {});
this.data = {
"crypto": {
last_updated: null,
current: null
},
"fiat": {
last_updated: null,
current: null
}
};
this.options = Object.assign({ cryptoInterval: helpers_1.isBrowser ? 15 * 1e3 : (5 * 1e3), fiatInterval: (60 * 1e3 * 60), calculateAverage: true, onUpdate: undefined, serverSideCCAPI: false, refreshCryptoList: true }, (this.exchanges.reduce((o, exchange) => (Object.assign(Object.assign({}, o), { [exchange]: true })), {})));
this.isReady = false;
this.isRunning = false;
this.options = Object.assign(Object.assign({}, this.options), options);
if (options.hasOwnProperty('HTTPAgent')) {
api_1.default.set({
$options: {
fetch_agent: options.HTTPAgent
}
});
}
};
this.options = Object.assign(Object.assign({ crypto_interval: isBrowser ? 15 * 1e3 : (5 * 1e3), fiat_interval: (60 * 1e3 * 60), calculateAverage: true, onUpdate: undefined }, (this.exchanges.reduce((o, exchange) => (Object.assign(Object.assign({}, o), { [exchange]: true })), {}))), initialOptions);
this.log = function () {
}
log(..._) {
var _a, _b;
if (!isBrowser && ((_b = (_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV) === null || _b === void 0 ? void 0 : _b.startsWith('dev'))) {
if (!helpers_1.isBrowser && ((_b = (_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV) === null || _b === void 0 ? void 0 : _b.startsWith('dev'))) {
Array.from(arguments).forEach((arg) => {

@@ -53,192 +65,235 @@ console.log(arg);

}
};
this.isReady = false;
}
/**
* Options
*/
Prices.prototype.setOptions = function (o) {
let newOptions = typeof o === "function" ?
o(Object.assign({}, this.options)) :
(o || {});
if (isBrowser && !isNaN(newOptions.crypto_interval) && newOptions.crypto_interval < 10000) {
console.warn(`The minimum allowed interval on frontend is 10s.`);
}
//Check if new options affect exchanges
let exchangesUpdated = false, averageUpdated = newOptions.hasOwnProperty('calculateAverage') && newOptions.calculateAverage !== this.options.calculateAverage;
for (const exchange of this.exchanges) {
if (newOptions.hasOwnProperty(exchange) && newOptions[exchange] !== this.options[exchange]) {
exchangesUpdated = true;
break;
/**
* Options
*/
setOptions(o) {
let newOptions = typeof o === "function" ?
o(Object.assign({}, this.options)) :
(o || {});
if (helpers_1.isBrowser && !isNaN(newOptions.cryptoInterval) && newOptions.cryptoInterval < 10000) {
console.warn(`The minimum allowed interval on frontend is 10s.`);
}
}
//Save options
this.options = Object.assign(Object.assign(Object.assign({}, this.options), newOptions), { crypto_interval: isNaN(newOptions.crypto_interval) ? this.options.crypto_interval : Math.max(isBrowser ? 10000 : 1000, newOptions.crypto_interval), fiat_interval: isNaN(newOptions.fiat_interval) ? this.options.fiat_interval : Math.max(60 * 30 * 1e3, newOptions.fiat_interval) });
//Update current prices
if (isBrowser) {
if (exchangesUpdated || averageUpdated) {
return this.browserTicker();
if (newOptions.hasOwnProperty('HTTPAgent')) {
api_1.default.set({
$options: {
fetch_agent: newOptions.HTTPAgent
}
});
}
//Check if new options affect exchanges
let exchangesUpdated = false, averageUpdated = newOptions.hasOwnProperty('calculateAverage') && newOptions.calculateAverage !== this.options.calculateAverage;
for (const exchange of this.exchanges) {
if (newOptions.hasOwnProperty(exchange) && newOptions[exchange] !== this.options[exchange]) {
exchangesUpdated = true;
break;
}
}
//Save options
this.options = Object.assign(Object.assign(Object.assign({}, this.options), newOptions), { cryptoInterval: isNaN(newOptions.cryptoInterval) ? this.options.cryptoInterval : Math.max(helpers_1.isBrowser ? 10000 : 1000, newOptions.cryptoInterval), fiatInterval: isNaN(newOptions.fiatInterval) ? this.options.fiatInterval : Math.max(60 * 30 * 1e3, newOptions.fiatInterval) });
//Update current prices
if (helpers_1.isBrowser || this.options.serverSideCCAPI) {
if (exchangesUpdated || averageUpdated) {
return this.browserTicker();
}
}
else {
this.data.crypto.current = this.joinPrices(this.data);
}
return this;
}
else {
this.data.crypto.current = this.joinPrices(this.data);
updateCrypto() {
return __awaiter(this, void 0, void 0, function* () {
if (!this.data.crypto.last_updated) {
this.log("Updating crypto...");
}
const tickers = this.exchanges.reduce((o, exchange) => (Object.assign(Object.assign({}, o), { [exchange]: api_1.default[exchange].ticker })), {});
let currents = [], current = {};
for (const ticker in tickers) {
try {
this.data.crypto[ticker] = yield tickers[ticker]();
if (this.options[ticker]) {
currents.push(this.data.crypto[ticker]);
current = Object.assign(Object.assign({}, current), this.data.crypto[ticker]);
this.data.crypto.last_updated = (+new Date());
}
}
catch (err) {
this.data.crypto[ticker] = null;
console.error(`Failed fetching prices from ${ticker}`, err);
}
}
if (currents.length) {
this.data.crypto.current = this.options.calculateAverage ? Object.assign(Object.assign({}, current), (0, helpers_1.getAverage)(currents)) : current;
if (typeof this.options.onUpdate === "function") {
this.options.onUpdate(this.data.crypto);
}
}
return this;
});
}
return this;
};
Prices.prototype.updateCrypto = function () {
return __awaiter(this, void 0, void 0, function* () {
if (!this.data.crypto.last_updated) {
this.log("Updating crypto...");
}
const tickers = this.exchanges.reduce((o, exchange) => (Object.assign(Object.assign({}, o), { [exchange]: api_1.default[exchange].ticker })), {});
let currents = [], current = {};
for (const ticker in tickers) {
updateFiat() {
return __awaiter(this, void 0, void 0, function* () {
this.log("Updating fiat...");
try {
this.data.crypto[ticker] = yield tickers[ticker]();
if (this.options[ticker]) {
currents.push(this.data.crypto[ticker]);
current = Object.assign(Object.assign({}, current), this.data.crypto[ticker]);
this.data.crypto.last_updated = (+new Date());
this.data.fiat.current = yield api_1.default.fiat.all();
this.data.fiat.last_updated = (+new Date());
if (typeof this.options.onUpdate === "function") {
this.options.onUpdate(this.data.fiat, true);
}
}
catch (err) {
this.data.crypto[ticker] = null;
console.error(`Failed fetching prices from ${ticker}`, err);
console.error(`Failed fetching fiat prices from ECB`, err);
}
}
if (currents.length) {
this.data.crypto.current = this.options.calculateAverage ? Object.assign(Object.assign({}, current), (0, helpers_1.getAverage)(currents)) : current;
if (typeof this.options.onUpdate === "function") {
this.options.onUpdate(this.data.crypto);
return this;
});
}
updateLists() {
return __awaiter(this, void 0, void 0, function* () {
if (!this.data.crypto.last_updated) {
this.log("Updating top currency list...");
}
}
return this;
});
};
Prices.prototype.updateFiat = function () {
return __awaiter(this, void 0, void 0, function* () {
this.log("Updating fiat...");
try {
this.data.fiat.current = yield api_1.default.fiat.all();
this.data.fiat.last_updated = (+new Date());
if (typeof this.options.onUpdate === "function") {
this.options.onUpdate(this.data.fiat, true);
try {
const getTopList = yield api_1.default.coinmarketcap.top();
this.list.crypto = Object.keys(getTopList);
this.cryptoInfo = getTopList;
if (typeof this.onCryptoListRefresh == "function" && this.isReady) {
this.onCryptoListRefresh(this.list.crypto);
}
}
catch (err) {
console.error(`Failed fetching fiat prices from ECB`, err);
}
return this;
});
}
joinPrices(data) {
const exchangesData = this.exchanges.reduce((o, exchange) => (Object.assign(Object.assign({}, o), { [exchange]: data.crypto[exchange] })), {});
let currents = [], current = {};
for (const exchange in exchangesData) {
if (!this.options[exchange] || !exchangesData[exchange]) {
continue;
}
currents.push(exchangesData[exchange]);
current = Object.assign(Object.assign({}, current), exchangesData[exchange]);
}
catch (err) {
console.error(`Failed fetching fiat prices from ECB`, err);
}
return this;
});
};
Prices.prototype.updateLists = function () {
return __awaiter(this, void 0, void 0, function* () {
this.log("Updating top currency list...");
try {
const getTopList = yield api_1.default.coinmarketcap.top();
this.list.crypto = Object.keys(getTopList);
this.cryptoInfo = getTopList;
}
catch (err) {
console.error(`Failed fetching fiat prices from ECB`, err);
}
return this;
});
};
Prices.prototype.joinPrices = function (data) {
const exchangesData = this.exchanges.reduce((o, exchange) => (Object.assign(Object.assign({}, o), { [exchange]: data.crypto[exchange] })), {});
let currents = [], current = {};
for (const exchange in exchangesData) {
if (!this.options[exchange] || !exchangesData[exchange]) {
continue;
}
currents.push(exchangesData[exchange]);
current = Object.assign(Object.assign({}, current), exchangesData[exchange]);
return this.options.calculateAverage ? Object.assign(Object.assign({}, current), (0, helpers_1.getAverage)(currents)) : current;
}
return this.options.calculateAverage ? Object.assign(Object.assign({}, current), (0, helpers_1.getAverage)(currents)) : current;
};
Prices.prototype.browserTicker = function () {
return __awaiter(this, void 0, void 0, function* () {
try {
const currentOptions = this.options;
const disabledExchanges = this.exchanges.filter((exchange) => !currentOptions[exchange]);
const data = yield api_1.default.coinconvert.ticker(disabledExchanges.length ? {
'filterExchanges': disabledExchanges,
'noAverage': !this.options.calculateAverage ? true : undefined
} : {});
this.data = data;
if (typeof this.options.onUpdate === "function") {
this.options.onUpdate(this.data);
browserTicker() {
return __awaiter(this, void 0, void 0, function* () {
try {
const currentOptions = this.options;
const disabledExchanges = this.exchanges.filter((exchange) => !currentOptions[exchange]);
const data = yield api_1.default.coinconvert.ticker(disabledExchanges.length ? {
'filterExchanges': disabledExchanges,
'noAverage': !this.options.calculateAverage ? true : undefined
} : {});
this.data = data;
if (typeof this.options.onUpdate === "function") {
this.options.onUpdate(this.data);
}
}
}
catch (err) {
console.error(`Failed fetching prices from API`, err);
}
return this;
});
};
Prices.prototype.runBrowser = function () {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
if (typeof window !== "undefined" && window['__ccRunning']) {
throw new Error(`The crypto-convert worker seems to be already running.
catch (err) {
console.error(`Failed fetching prices from API`, err);
}
return this;
});
}
browserLists() {
return __awaiter(this, void 0, void 0, function* () {
try {
const getTopList = yield api_1.default.coinconvert.list();
this.list.crypto = Object.keys(getTopList.crypto);
this.list.fiat = getTopList.fiat;
this.cryptoInfo = getTopList.crypto;
if (typeof this.onCryptoListRefresh == "function" && this.isReady) {
this.onCryptoListRefresh(this.list.crypto);
}
}
catch (err) {
console.error('Failed fetching currencies list from API', err);
}
return this;
});
}
runBrowser() {
return __awaiter(this, void 0, void 0, function* () {
if (typeof window !== "undefined" && window['__ccRunning']) {
throw new Error(`The crypto-convert worker seems to be already running.
- There might be an issue with the way your app imports javascript dependencies.
- Make sure to call 'convert.stop()' on component unmounts if you are using SPA frameworks (e.g React).`);
}
//First run only
if (!this.isReady) {
yield this.browserTicker();
//Update lists
yield this.browserLists();
if (!this.isRunning) {
return false;
}
if (!helpers_1.isBrowser && this.options.serverSideCCAPI && this.options.refreshCryptoList) {
this.lists_worker = setInterval(this.browserLists.bind(this), 86400 //every day
);
}
}
this.crypto_worker = setInterval(this.browserTicker.bind(this), this.options.cryptoInterval);
this.isReady = true;
if (typeof window !== "undefined") {
window['__ccRunning'] = true;
if (window['__ccRunID']) {
clearInterval(window['__ccRunID']);
}
window['__ccRunID'] = this.crypto_worker;
}
return this;
});
}
runServer() {
return __awaiter(this, void 0, void 0, function* () {
yield this.updateLists();
yield this.updateFiat();
yield this.updateCrypto();
if (!this.isRunning) {
return false;
}
this.isReady = true;
this.crypto_worker = setInterval(this.updateCrypto.bind(this), this.options.cryptoInterval);
this.fiat_worker = setInterval(this.updateFiat.bind(this), this.options.fiatInterval);
if (this.options.refreshCryptoList) {
this.lists_worker = setInterval(this.updateLists.bind(this), 86400 //every day
);
}
return this;
});
}
run() {
if (this.isRunning || this.crypto_worker) {
throw new Error("Crypto-convert is already running.");
}
//First run only
if (!((_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.crypto) === null || _b === void 0 ? void 0 : _b.current)) {
yield this.browserTicker();
//Update lists
const getTopList = yield api_1.default.coinconvert.list();
this.list.crypto = Object.keys(getTopList.crypto);
this.list.fiat = getTopList.fiat;
this.cryptoInfo = getTopList.crypto;
this.isRunning = true;
if (helpers_1.isBrowser || this.options.serverSideCCAPI) {
return this.runBrowser();
}
this.isReady = true;
if (this.crypto_worker) {
clearInterval(this.crypto_worker);
return this.runServer();
}
stop() {
console.log(this.isRunning, this.crypto_worker);
this.isRunning = false;
clearInterval(this.crypto_worker);
clearInterval(this.fiat_worker);
this.crypto_worker = null;
this.fiat_worker = null;
if (this.lists_worker) {
clearInterval(this.lists_worker);
this.lists_worker = null;
}
this.crypto_worker = setInterval(this.browserTicker.bind(this), this.options.crypto_interval);
if (typeof window !== "undefined") {
window['__ccRunning'] = true;
if (window['__ccRunID']) {
clearInterval(window['__ccRunID']);
}
window['__ccRunID'] = this.crypto_worker;
window['__ccRunning'] = false;
}
return this;
});
};
Prices.prototype.runServer = function () {
return __awaiter(this, void 0, void 0, function* () {
yield this.updateLists();
yield this.updateFiat();
yield this.updateCrypto();
this.isReady = true;
this.crypto_worker = setInterval(this.updateCrypto.bind(this), this.options.crypto_interval);
this.fiat_worker = setInterval(this.updateFiat.bind(this), this.options.fiat_interval);
return this;
});
};
Prices.prototype.run = function () {
this.isRunning = true;
if (isBrowser) {
return this.runBrowser();
}
return this.runServer();
};
Prices.prototype.stop = function () {
clearInterval(this.crypto_worker);
clearInterval(this.fiat_worker);
this.isRunning = false;
if (typeof window !== "undefined") {
window['__ccRunning'] = false;
restart() {
return this.stop().run();
}
return this;
};
Prices.prototype.restart = function () {
return this.stop().run();
};
const PricesWorker = new Prices();
exports.WorkerReady = PricesWorker.run();
}
exports.default = PricesWorker;
{
"name": "crypto-convert",
"version": "2.0.5",
"version": "2.1.0",
"description": "Convert crypto to fiat and vice-versa instantly.",

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

@@ -18,9 +18,15 @@

## HTTP API
Free public API
`https://api.coinconvert.net/convert/btc/usd?amount=1`
## Installation
`npm i crypto-convert`
### Import
```javascript
import convert from 'crypto-convert';
import CryptoConvert from 'crypto-convert';
```

@@ -30,10 +36,17 @@

```javascript
const convert = require("crypto-convert").default;
const CryptoConvert = require("crypto-convert").default;
```
## CDN For Browsers
```html
<script src='https://coinconvert.net/assets/js/crypto-convert.min.js'></script>
```
## Usage
```javascript
const convert = new CryptoConvert(/*options?*/);
(async function(){
await convert.ready(); //Cache is not yet loaded on first run
await convert.ready(); //Wait for the initial cache to load

@@ -45,2 +58,5 @@ convert.BTC.USD(1);

//... convert any pair
// prices are automatically updated on background
})();

@@ -51,6 +67,8 @@ ```

Here are the available options you can specify on initialization:
```javascript
convert.setOptions({
crypto_interval: 5000, //Crypto prices update interval in ms , (default: 5 seconds on Node.js/15 seconds on Browsers)
fiat_interval: (60 * 1e3 * 60), //Fiat prices update interval, default every 1 hour (only on Node.js)
new CryptoConvert({
cryptoInterval: 5000, //Crypto prices update interval in ms (default 5 seconds on Node.js & 15 seconds on Browsers)
fiatInterval: (60 * 1e3 * 60), //Fiat prices update interval (default every 1 hour)
calculateAverage: true, //Calculate the average crypto price from exchanges

@@ -61,16 +79,8 @@ binance: true, //Use binance rates

kraken: true, //Use kraken rates
onUpdate: (tickers, isFiatUpdate?)=> any //Callback on every crypto update
onUpdate: (tickers, isFiatUpdate?)=> any //Callback on every crypto update
HTTPAgent: null //HTTP Agent for server-side proxies (Node.js only)
});
```
## HTTP API
Free public API
`https://api.coinconvert.net/convert/btc/usd?amount=1`
## CDN
```html
<script src='https://coinconvert.net/assets/js/crypto-convert.min.js'></script>
```
## Other Parameters

@@ -124,7 +134,7 @@

'USD', //The quote fiat price. Must be a supported fiat currency.
async fetchPrice()=>{
//...call the api here
async ()=>{
//...call your api here
return price;
},
10000 //Update interval in ms
5000 //Update interval in ms
);

@@ -131,0 +141,0 @@ ```

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc