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 1.1.2 to 1.1.3

2

cdn/crypto-convert.min.js

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

!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 n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function a(t){try{c(n.next(t))}catch(t){o(t)}}function s(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))};function i(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)}),c=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 n=s(t.$options||{});return delete t.$options,Object.assign(Object.assign({},n),{values:Object.assign(Object.assign({},n.values),t)})},u=(t,e,r=!1)=>{let n=r?t||{}:s(t||{}),i=s(e||{});return i.headers=Object.assign(Object.assign({},n.headers),i.headers),i.params=Object.assign(Object.assign({},n.params),i.params),i.values=Object.assign(Object.assign({},n.values),i.values),Object.assign(n,i),n};t=Object.assign({},t);let l={base:"",headers:{"User-Agent":"Rests JS (v1.0.9)"},params:{},values:{},on_error:void 0,on_success:void 0,on_request:void 0,fetch_agent:null};u(l,(null==t?void 0:t.$options)||{},!0),u(l,e,!0);const p={json:"application/json",form:"multipart/form-data",urlencoded:"application/x-www-form-urlencoded",text:"text/plain"},d=Object.values(p),f=["headers","body","query","path"],h={POST:"body",GET:"query"},_={"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}}}},y=t=>null==t,v=(...t)=>{for(var e=0;e<t.length;e++)if(null!==t[e]&&void 0!==t[e])return t[e];return null},m=(t,e,r,i)=>n(this,void 0,void 0,(function*(){return o(t,e).then((function(t){var e;return n(this,void 0,void 0,(function*(){try{var n=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"},c=Object.keys(s).find((t=>new RegExp(t).test(n)))||"text";if(a[s[c]]=yield t[s[c]](),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,i);if(void 0!==t)return t}return a}catch(t){if(r.on_error){let e=r.on_error(t,i);if(void 0!==e)return e}return Promise.reject(t)}}))}))}));function b(t,e,r){t.method=(t.method||"get").toUpperCase(),t.params=t.params||{};const i=function(o){var a,s,c,g,w,O;return n(this,void 0,void 0,(function*(){if(this instanceof i)throw new Error("This is an endpoint, you can't initialize this.");var n=u(l,e);n.on_request=t.on_request||n.on_request,n.on_success=t.on_success||n.on_success,n.on_error=t.on_error||n.on_error;var x=`${n.base}${t.path}`;((null==o?void 0:o.$sandbox)||(null===(a=null==n?void 0:n.values)||void 0===a?void 0:a.$sandbox))&&(x=`${n.sandboxBase||n.base}${t.path}`);var j,E,k={method:t.method,headers:Object.assign({},n.headers),agent:n.fetch_agent},N=d.includes(t.enctype)?t.enctype:p[t.enctype||"json"],S=Object.assign({},n.params,t.params),A=_[N](),D=new URLSearchParams;for(var T in"FormData"==(null===(s=null==o?void 0:o.constructor)||void 0===s?void 0:s.name)?(j=o,o=Object.fromEntries(Array.from(j.keys(),(t=>t.endsWith("[]")?[t.slice(0,-2),j.getAll(t)]:[t,j.get(t)])))):o=o||{},S){var U=S[T],C=o[T],R=null===(c=null==n?void 0:n.values)||void 0===c?void 0:c[T],P=U.default,$=(null==o?void 0:o.$sandbox)||(null===(g=null==n?void 0:n.values)||void 0===g?void 0:g.$sandbox)?U.example:void 0,B=v(C,R,$,P),M=U.name||T,L=U.help||`The '${T}' field is invalid.`;if(U.required&&y(B))throw(I=new Error(L)).field=T,I;if(!y(B)){if("function"==typeof U.format)try{B=U.format(B)}catch(t){throw(I=new Error(t.message||L)).field=T,I}if(U.type&&"any"!==U.type&&((I=new Error(L)).field=T,["string","boolean","number"].includes(U.type)&&typeof B!=U.type||"array"==U.type&&!Array.isArray(B)||"object"==U.type&&(!B||"Object"!==B.__proto__.constructor.name)))throw I;if(U.validate&&("RegExp"==(null===(O=null===(w=U.validate)||void 0===w?void 0:w.constructor)||void 0===O?void 0:O.name)&&(U.validate.toJSON=function(){return U.validate.toString().replace(/^\//g,"").replace(/\/$/g,"")}),!new RegExp(U.validate).test(B)))throw(I=new Error(L)).field=T,I;if("number"==U.type){var I;if(U.hasOwnProperty("max")&&!isNaN(U.max)&&Number(B)>Number(U.max))throw(I=new Error(`The maximum allowed value allowed for the ${M} parameter is ${U.max}`)).field=T,I;if(U.hasOwnProperty("min")&&!isNaN(U.min)&&Number(B)<Number(U.min))throw(I=new Error(`The minimum allowed value allowed for the ${M} parameter is ${U.min}`)).field=T,I}if(U.in&&Array.isArray(U.in)&&!U.in.includes(B))throw(I=new Error(`The ${M} parameter should be one of these values: ${U.in}`)).field=T,I;var F="string"==typeof U.location?U.location.toLowerCase():h[k.method];if(!F||!f.includes(F))throw new Error(`Invalid location for '${T}' field.`);"headers"!=F?"body"!=F?"query"!=F?"path"==F&&(x=x.replace(new RegExp(`{${(E=M,E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).trim()}}`),B)):D.append(M,B):A.append(M,B):(k.headers=k.headers||{},k.headers[M]=B)}}var H=D.toString();H&&(x=`${x}?${H}`),A.keys&&(t=>{for(var e of t)return!1;return!0})(A.keys())||A.getLengthSync&&0==A.getLengthSync()||A.isEmpty&&A.isEmpty()||(k.body=A.toString()),k.body&&"multipart/form-data"!==N&&(k.headers=k.headers||{},k.headers["Content-Type"]=N);let q={url:x,options:k,params:o,key:r,instance:l.__$root_instance__,self:b(t,e,r)};if(n.on_request){var X=yield Promise.resolve(n.on_request(q));if(X){if(!(null==X?void 0:X.url)&&!(null==X?void 0:X.options))return X;x=X.url||x,k=X.options||k}if(!1===X)return!1}return m(x,k,n,q)}))};return i}function g(e,r,n,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 p=u(l,r),d=c(s),f=u(p,d);return i(n?(h=t,n.split(".").reduce(((t,e)=>null==t?void 0:t[e]),h)):t,f);var h}};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=c(t);return u(l,r,!0),a[e]}),a[e]}const w=Object.defineProperty(g("Rests",l,void 0,!0),"__schema__",{value:{schema:t,options:l},writable:!1,enumerable:!1});return l.__$root_instance__=w,function t(e,r,n,i){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 c=`${i?i+".":""}${o}`;if(a.hasOwnProperty("path")){var s=a;e[o]=b(s,n,c)}else{if("$"===o.substr(0,1))continue;let r=n;(null==a?void 0:a.$options)&&(r=u(n,null==a?void 0:a.$options)),e[o]=t(g(o,r,c),a,r,c)}}return e}(w,t,{})}Object.defineProperty(e,"__esModule",{value:!0}),i.default=i,e.default=i,t.exports=i},203:function(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(r(945)),o=r(382),a=(0,i.default)({binance:{$options:{base:"https://api.binance.com/api/v3"},ticker:{path:"/ticker/price",on_success(t,e){const r={USDT:"USD",USDC:"USD",BUSD:"USD"},n=t.json;if(!n||!Array.isArray(n))throw new Error(`Invalid response from Binance: ${JSON.stringify(n)}`);return n.reduce(((t,e)=>{const n=(0,o.symbolMap)(e.symbol,r),i=parseFloat(e.price);return t[n]=i,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 n=(0,o.symbolMap)(r[0].replace(/^t/,""),e).replace(":",""),i=parseFloat(r[7]);return t[n]=i,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,n)=>{const i=e+r.currency,o=1/parseFloat(r.rates[e]);return t[i]=o,t}),{})}}},coinmarketcap:{$options:{base:"https://api.coinmarketcap.com/data-api/v3"},top:{path:"/map/all",params:{limit:{default:"100"},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.map((t=>t.symbol))}}},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),n=e.match(/(?<=rate=["'])([.0-9]+)/gi),i=r.reduce(((t,e,r)=>Object.assign(Object.assign({},t),{[e]:n[r]})),{});return i.EUR=1,i}}},coinconvert:{ticker:{path:"https://api.coinconvert.net/v2/ticker?v=1.1.1",on_success:t=>t.json},list:{path:"https://api.coinconvert.net/list?v=1.1.1",on_success:t=>t.json}}});e.default=a},382:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatNumber=e.getAverage=e.symbolMap=void 0,e.symbolMap=function(t,e){const r=Object.keys(e);for(var n=0;n<r.length;n++)if(t.length>=r[n].length+3&&(t.endsWith(r[n])||t.startsWith(r[n])))return t.replace(r[n],e[r[n]]);return t},e.getAverage=function(t){return t.length?Object.keys(t[0]).reduce(((e,r)=>{let n=t.map((t=>t[r])).filter((t=>t)),i=n.reduce(((t,e)=>t+e),0)/n.length;return e[r]=i,e}),{}):{}},e.formatNumber=function(t,e){if("number"!=typeof t&&(t=Number(t),isNaN(t)))return NaN;let r="number"==typeof e?t.toFixed(e):t+"",n=r.match(/\./)?r.replace(/0+$/g,"").replace(/\.+$/g,""):r;return parseFloat(n)}},607:function(module,exports,__webpack_require__){var __createBinding=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=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,n){return new(r||(r=Promise))((function(i,o){function a(t){try{c(n.next(t))}catch(t){o(t)}}function s(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0});const helpers_1=__webpack_require__(382),worker_1=__importStar(__webpack_require__(827));function isEmpty(t){if(!t)return!0;for(var e in t)return!1;return!0}const coins=worker_1.default.list.crypto,fiats=worker_1.default.list.fiat;function getPrice(t,e="USD"){return 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)}const exchangeWrap=function(){const all_currencies=coins.concat(fiats),exchange={get isReady(){return worker_1.default.isReady}},wrapper=function(t,e){var r=e;return function(e){if(isEmpty(worker_1.default.data.crypto.current)||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 n=worker_1.default.data.fiat.current;if(r==t)return e;if(coins.includes(t)&&coins.includes(r)){let n=getPrice(t,r)||wrapper("USD",r)(wrapper(t,"USD")(1));return(0,helpers_1.formatNumber)(n*e,8)}if(n[t]&&n[r])return(0,helpers_1.formatNumber)(e/n[t]*n[r],2);var i=function(t){return getPrice(t)||wrapper("BTC","USD")(getPrice(t,"BTC"))||wrapper("ETH","USD")(getPrice(t,"ETH"))};if(n[r]){let o=i(t)/n.USD*n[r];return(0,helpers_1.formatNumber)(o*e,4)}if(n[t]){let o=i(r)/n.USD*n[t];return(0,helpers_1.formatNumber)(e/o,8)}return null}};let types="";const initialize=function(){types+="type amount = (amount: number | string) => number | false | null;",types+="\nexport interface Pairs {";for(var t=0;t<all_currencies.length;t++){var e=all_currencies[t];if(e&&"string"==typeof e){exchange[e]||(exchange[e]={}),types+=`\n\t'${e.replace(/\'/g,"\\'")}': {`;for(var r=0;r<all_currencies.length;r++){var n=all_currencies[r];n&&"string"==typeof n&&(exchange[e][n]=wrapper(e,n),types+=`\n\t\t'${n.replace(/\'/g,"\\'")}': amount,`)}types+="\n},"}}types+="\n}"}();return exchange.setOptions=function(t){return worker_1.default.setOptions(t)},exchange.stop=function(){return worker_1.default.stop()},exchange.start=function(){return worker_1.default.restart()},exchange.ready=function(){return __awaiter(this,void 0,void 0,(function*(){return yield Promise.resolve(worker_1.WorkerReady),exchange}))},exchange.list={crypto:coins,fiat:fiats},exchange.ticker={get crypto(){return worker_1.default.data.crypto},get fiat(){return worker_1.default.data.fiat}},exchange.from=function(t){return this.coin=t.toUpperCase(),this},exchange.from.prototype.to=function(t){return this.currency=t.toUpperCase(),this},exchange.from.prototype.amount=function(t=1){return!!(this.coin&&this.currency&&exchange[this.coin]&&exchange[this.currency])&&exchange[this.coin][this.currency](t)},"undefined"==typeof window&&"undefined"!=typeof process&&function(){__awaiter(this,void 0,void 0,(function*(){try{eval("\n\t\t\t\t\tconst fs = require('fs');\n\t\t\t\t\tconst path = require('path');\n\t\t\t\t\tconst isDist = path.basename(__dirname) == 'dist';\n\t\t\t\t\tconst typesFile = path.join(__dirname, isDist ? 'paris.d.ts' : 'paris.ts');\n\n\t\t\t\t\tfs.writeFileSync(typesFile, types, 'utf-8');\n\t\t\t\t")}catch(t){console.warn(t)}}))}(),exchange}(),convert=exchangeWrap;convert.default=convert,module.exports&&(module.exports=convert),exports.default=convert},827:function(t,e,r){var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function a(t){try{c(n.next(t))}catch(t){o(t)}}function s(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.WorkerReady=void 0;const o=i(r(203)),a=r(382),s="undefined"!=typeof window&&window.document;function c(t={}){this.list={crypto:["BTC","ETH","USDT","XRP","DOT","ADA","LTC","LINK","BCH","BNB","XLM","USDC","UNI","WBTC","DOGE","AAVE","BSV","EOS","XMR","XEM","TRX","XTZ","THETA","SNX","ATOM","VET","SUSHI","DAI","NEO","MKR","COMP","CRO","HT","BUSD","SOL","LEO","MIOTA","FTT","CEL","EGLD","DASH","UMA","AVAX","FIL","ZEC","LUNA","GRT","YFI","KSM","REV","ETC","DCR","ALGO","ZIL","CHSB","WAVES","NEAR","LRC","HBAR","REN","OMG","NEXO","RUNE","RENBTC","VGX","CELO","CRV","1INCH","ZRX","ONT","HEDG","BAT","NANO","HUSD","ICX","BTT","QNT","DGB","SC","TUSD","ZEN","OKB","RSR","ALPHA","QTUM","STX","FTM","AMPL","FUN","KNC","ENJ","IOST","MANA","XVG","UST","OCEAN","BTCB","BNT","PAX","BAND"],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.data={crypto:{last_update:null,current:null},fiat:{last_update:null,current:null}},this.options=Object.assign({crypto_interval:5e3,fiat_interval:36e5,calculateAverage:!0,binance:!0,coinbase:!0,bitfinex:!0,onUpdate:void 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}c.prototype.setOptions=function(t){let e="function"==typeof t?t(Object.assign({},this.options)):t||{};return this.options=Object.assign(Object.assign(Object.assign({},this.options),e),{crypto_interval:isNaN(e.crypto_interval)?this.options.crypto_interval:Math.min(1e3,e.crypto_interval),fiat_interval:isNaN(e.fiat_interval)?this.options.fiat_interval:Math.min(5e3,e.fiat_interval)}),this.data.crypto.current=this.joinPrices(this.data),this},c.prototype.updateCrypto=function(){return n(this,void 0,void 0,(function*(){this.data.crypto.last_updated||this.log("Updating crypto...");const t={binance:o.default.binance.ticker,bitfinex:o.default.bitfinex.ticker,coinbase:o.default.coinbase.ticker};let e=[],r={};for(const n in t)try{this.data.crypto[n]=yield t[n](),this.options[n]&&(e.push(this.data.crypto[n]),r=Object.assign(Object.assign({},r),this.data.crypto[n]),this.data.crypto.last_updated=+new Date)}catch(t){this.data.crypto[n]=null,console.error(`Failed fetching prices from ${n}`,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}))},c.prototype.updateFiat=function(){return n(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}))},c.prototype.updateLists=function(){return n(this,void 0,void 0,(function*(){this.log("Updating top currency list...");try{this.list.crypto=yield o.default.coinmarketcap.top()}catch(t){console.error("Failed fetching fiat prices from ECB",t)}return this}))},c.prototype.joinPrices=function(t){const e={binance:t.crypto.binance,coinbase:t.crypto.coinbase,bitfinex:t.crypto.bitfinex};let r=[],n={};for(const t in e)this.options[t]&&e[t]&&(r.push(e[t]),n=Object.assign(Object.assign({},n),e[t]));return this.options.calculateAverage?Object.assign(Object.assign({},n),(0,a.getAverage)(r)):n},c.prototype.browserTicker=function(){return n(this,void 0,void 0,(function*(){try{const t=yield o.default.coinconvert.ticker();let e=this.joinPrices(t);this.data=Object.assign(Object.assign({},t),{crypto:Object.assign(Object.assign({},t.crypto),{current:e})}),"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data)}catch(t){console.error("Failed fetching prices from API",t)}return this}))},c.prototype.runBrowser=function(){return n(this,void 0,void 0,(function*(){return yield this.browserTicker(),this.list=yield o.default.coinconvert.list(),this.isReady=!0,this.crypto_worker&&clearInterval,this.crypto_worker=setInterval(this.browserTicker.bind(this),this.options.crypto_interval),this}))},c.prototype.runServer=function(){return n(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}))},c.prototype.run=function(){return this.isRunning=!0,s?this.runBrowser():this.runServer()},c.prototype.stop=function(){return clearInterval(this.crypto_worker),clearInterval(this.fiat_worker),this.isRunning=!1,this},c.prototype.restart=function(){return this.stop().run()};const u=new c;e.WorkerReady=u.run(),e.default=u},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__})()));
!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 n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function a(t){try{c(n.next(t))}catch(t){o(t)}}function s(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))};function i(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)}),c=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 n=s(t.$options||{});return delete t.$options,Object.assign(Object.assign({},n),{values:Object.assign(Object.assign({},n.values),t)})},u=(t,e,r=!1)=>{let n=r?t||{}:s(t||{}),i=s(e||{});return i.headers=Object.assign(Object.assign({},n.headers),i.headers),i.params=Object.assign(Object.assign({},n.params),i.params),i.values=Object.assign(Object.assign({},n.values),i.values),Object.assign(n,i),n};t=Object.assign({},t);let l={base:"",headers:{"User-Agent":"Rests JS (v1.0.9)"},params:{},values:{},on_error:void 0,on_success:void 0,on_request:void 0,fetch_agent:null};u(l,(null==t?void 0:t.$options)||{},!0),u(l,e,!0);const p={json:"application/json",form:"multipart/form-data",urlencoded:"application/x-www-form-urlencoded",text:"text/plain"},d=Object.values(p),f=["headers","body","query","path"],h={POST:"body",GET:"query"},_={"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}}}},y=t=>null==t,v=(...t)=>{for(var e=0;e<t.length;e++)if(null!==t[e]&&void 0!==t[e])return t[e];return null},m=(t,e,r,i)=>n(this,void 0,void 0,(function*(){return o(t,e).then((function(t){var e;return n(this,void 0,void 0,(function*(){try{var n=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"},c=Object.keys(s).find((t=>new RegExp(t).test(n)))||"text";if(a[s[c]]=yield t[s[c]](),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,i);if(void 0!==t)return t}return a}catch(t){if(r.on_error){let e=r.on_error(t,i);if(void 0!==e)return e}return Promise.reject(t)}}))}))}));function b(t,e,r){t.method=(t.method||"get").toUpperCase(),t.params=t.params||{};const i=function(o){var a,s,c,g,w,O;return n(this,void 0,void 0,(function*(){if(this instanceof i)throw new Error("This is an endpoint, you can't initialize this.");var n=u(l,e);n.on_request=t.on_request||n.on_request,n.on_success=t.on_success||n.on_success,n.on_error=t.on_error||n.on_error;var x=`${n.base}${t.path}`;((null==o?void 0:o.$sandbox)||(null===(a=null==n?void 0:n.values)||void 0===a?void 0:a.$sandbox))&&(x=`${n.sandboxBase||n.base}${t.path}`);var j,E,k={method:t.method,headers:Object.assign({},n.headers),agent:n.fetch_agent},N=d.includes(t.enctype)?t.enctype:p[t.enctype||"json"],S=Object.assign({},n.params,t.params),A=_[N](),D=new URLSearchParams;for(var T in"FormData"==(null===(s=null==o?void 0:o.constructor)||void 0===s?void 0:s.name)?(j=o,o=Object.fromEntries(Array.from(j.keys(),(t=>t.endsWith("[]")?[t.slice(0,-2),j.getAll(t)]:[t,j.get(t)])))):o=o||{},S){var U=S[T],C=o[T],R=null===(c=null==n?void 0:n.values)||void 0===c?void 0:c[T],P=U.default,$=(null==o?void 0:o.$sandbox)||(null===(g=null==n?void 0:n.values)||void 0===g?void 0:g.$sandbox)?U.example:void 0,B=v(C,R,$,P),M=U.name||T,L=U.help||`The '${T}' field is invalid.`;if(U.required&&y(B))throw(I=new Error(L)).field=T,I;if(!y(B)){if("function"==typeof U.format)try{B=U.format(B)}catch(t){throw(I=new Error(t.message||L)).field=T,I}if(U.type&&"any"!==U.type&&((I=new Error(L)).field=T,["string","boolean","number"].includes(U.type)&&typeof B!=U.type||"array"==U.type&&!Array.isArray(B)||"object"==U.type&&(!B||"Object"!==B.__proto__.constructor.name)))throw I;if(U.validate&&("RegExp"==(null===(O=null===(w=U.validate)||void 0===w?void 0:w.constructor)||void 0===O?void 0:O.name)&&(U.validate.toJSON=function(){return U.validate.toString().replace(/^\//g,"").replace(/\/$/g,"")}),!new RegExp(U.validate).test(B)))throw(I=new Error(L)).field=T,I;if("number"==U.type){var I;if(U.hasOwnProperty("max")&&!isNaN(U.max)&&Number(B)>Number(U.max))throw(I=new Error(`The maximum allowed value allowed for the ${M} parameter is ${U.max}`)).field=T,I;if(U.hasOwnProperty("min")&&!isNaN(U.min)&&Number(B)<Number(U.min))throw(I=new Error(`The minimum allowed value allowed for the ${M} parameter is ${U.min}`)).field=T,I}if(U.in&&Array.isArray(U.in)&&!U.in.includes(B))throw(I=new Error(`The ${M} parameter should be one of these values: ${U.in}`)).field=T,I;var F="string"==typeof U.location?U.location.toLowerCase():h[k.method];if(!F||!f.includes(F))throw new Error(`Invalid location for '${T}' field.`);"headers"!=F?"body"!=F?"query"!=F?"path"==F&&(x=x.replace(new RegExp(`{${(E=M,E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).trim()}}`),B)):D.append(M,B):A.append(M,B):(k.headers=k.headers||{},k.headers[M]=B)}}var H=D.toString();H&&(x=`${x}?${H}`),A.keys&&(t=>{for(var e of t)return!1;return!0})(A.keys())||A.getLengthSync&&0==A.getLengthSync()||A.isEmpty&&A.isEmpty()||(k.body=A.toString()),k.body&&"multipart/form-data"!==N&&(k.headers=k.headers||{},k.headers["Content-Type"]=N);let q={url:x,options:k,params:o,key:r,instance:l.__$root_instance__,self:b(t,e,r)};if(n.on_request){var X=yield Promise.resolve(n.on_request(q));if(X){if(!(null==X?void 0:X.url)&&!(null==X?void 0:X.options))return X;x=X.url||x,k=X.options||k}if(!1===X)return!1}return m(x,k,n,q)}))};return i}function g(e,r,n,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 p=u(l,r),d=c(s),f=u(p,d);return i(n?(h=t,n.split(".").reduce(((t,e)=>null==t?void 0:t[e]),h)):t,f);var h}};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=c(t);return u(l,r,!0),a[e]}),a[e]}const w=Object.defineProperty(g("Rests",l,void 0,!0),"__schema__",{value:{schema:t,options:l},writable:!1,enumerable:!1});return l.__$root_instance__=w,function t(e,r,n,i){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 c=`${i?i+".":""}${o}`;if(a.hasOwnProperty("path")){var s=a;e[o]=b(s,n,c)}else{if("$"===o.substr(0,1))continue;let r=n;(null==a?void 0:a.$options)&&(r=u(n,null==a?void 0:a.$options)),e[o]=t(g(o,r,c),a,r,c)}}return e}(w,t,{})}Object.defineProperty(e,"__esModule",{value:!0}),i.default=i,e.default=i,t.exports=i},203:function(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(r(945)),o=r(382),a=(0,i.default)({binance:{$options:{base:"https://api.binance.com/api/v3"},ticker:{path:"/ticker/price",on_success(t,e){const r={USDT:"USD",USDC:"USD",BUSD:"USD"},n=t.json;if(!n||!Array.isArray(n))throw new Error(`Invalid response from Binance: ${JSON.stringify(n)}`);return n.reduce(((t,e)=>{const n=(0,o.symbolMap)(e.symbol,r),i=parseFloat(e.price);return t[n]=i,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 n=(0,o.symbolMap)(r[0].replace(/^t/,""),e).replace(":",""),i=parseFloat(r[7]);return t[n]=i,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,n)=>{const i=e+r.currency,a=(0,o.formatNumber)(1/parseFloat(r.rates[e]),8);return t[i]=a,t}),{})}}},coinmarketcap:{$options:{base:"https://api.coinmarketcap.com/data-api/v3"},top:{path:"/map/all",params:{limit:{default:"100"},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.map((t=>t.symbol))}}},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),n=e.match(/(?<=rate=["'])([.0-9]+)/gi),i=r.reduce(((t,e,r)=>Object.assign(Object.assign({},t),{[e]:n[r]})),{});return i.EUR=1,i}}},coinconvert:{ticker:{path:"https://api.coinconvert.net/v2/ticker?v=1.1.3",on_success:t=>t.json},list:{path:"https://api.coinconvert.net/list?v=1.1.3",on_success:t=>t.json}}});e.default=a},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+"",n=r.match(/\./)?r.replace(/0+$/g,"").replace(/\.+$/g,""):r;return parseFloat(n)}Object.defineProperty(e,"__esModule",{value:!0}),e.formatNumber=e.getAverage=e.symbolMap=void 0,e.symbolMap=function(t,e){const r=Object.keys(e);for(var n=0;n<r.length;n++)if(t.length>=r[n].length+3&&(t.endsWith(r[n])||t.startsWith(r[n])))return t.replace(r[n],e[r[n]]);return t},e.getAverage=function(t){return t.length?Object.keys(t[0]).reduce(((e,n)=>{let i=t.map((t=>t[n])).filter((t=>t)),o=r(i.reduce(((t,e)=>t+e),0)/i.length,8);return e[n]=o,e}),{}):{}},e.formatNumber=r},607:function(module,exports,__webpack_require__){var __createBinding=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=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,n){return new(r||(r=Promise))((function(i,o){function a(t){try{c(n.next(t))}catch(t){o(t)}}function s(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0});const helpers_1=__webpack_require__(382),worker_1=__importStar(__webpack_require__(827));function isEmpty(t){if(!t)return!0;for(var e in t)return!1;return!0}const coins=worker_1.default.list.crypto,fiats=worker_1.default.list.fiat;function getPrice(t,e="USD"){return 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)}const exchangeWrap=function(){const all_currencies=coins.concat(fiats),exchange={get isReady(){return worker_1.default.isReady}},wrapper=function(t,e){var r=e;return function(e){if(isEmpty(worker_1.default.data.crypto.current)||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 n=worker_1.default.data.fiat.current;if(r==t)return e;if(coins.includes(t)&&coins.includes(r)){let n=getPrice(t,r)||wrapper("USD",r)(wrapper(t,"USD")(1));return(0,helpers_1.formatNumber)(n*e,8)}if(n[t]&&n[r])return(0,helpers_1.formatNumber)(e/n[t]*n[r],2);var i=function(t){return getPrice(t)||wrapper("BTC","USD")(getPrice(t,"BTC"))||wrapper("ETH","USD")(getPrice(t,"ETH"))};if(n[r]){let o=i(t)/n.USD*n[r];return(0,helpers_1.formatNumber)(o*e,4)}if(n[t]){let o=i(r)/n.USD*n[t];return(0,helpers_1.formatNumber)(e/o,8)}return null}};let types="";const initialize=function(){types+="type amount = (amount: number | string) => number | false | null;",types+="\nexport interface Pairs {";for(var t=0;t<all_currencies.length;t++){var e=all_currencies[t];if(e&&"string"==typeof e){exchange[e]||(exchange[e]={}),types+=`\n\t'${e.replace(/\'/g,"\\'")}': {`;for(var r=0;r<all_currencies.length;r++){var n=all_currencies[r];n&&"string"==typeof n&&(exchange[e][n]=wrapper(e,n),types+=`\n\t\t'${n.replace(/\'/g,"\\'")}': amount,`)}types+="\n},"}}types+="\n}"}();return exchange.setOptions=function(t){return worker_1.default.setOptions(t)},exchange.stop=function(){return worker_1.default.stop()},exchange.start=function(){return worker_1.default.restart()},exchange.ready=function(){return __awaiter(this,void 0,void 0,(function*(){return yield Promise.resolve(worker_1.WorkerReady),exchange}))},exchange.list={crypto:coins,fiat:fiats},exchange.ticker={get crypto(){return worker_1.default.data.crypto},get fiat(){return worker_1.default.data.fiat}},exchange.from=function(t){return this.coin=t.toUpperCase(),this},exchange.from.prototype.to=function(t){return this.currency=t.toUpperCase(),this},exchange.from.prototype.amount=function(t=1){return!!(this.coin&&this.currency&&exchange[this.coin]&&exchange[this.currency])&&exchange[this.coin][this.currency](t)},"undefined"==typeof window&&"undefined"!=typeof process&&function(){__awaiter(this,void 0,void 0,(function*(){try{eval("\n\t\t\t\t\tconst fs = require('fs');\n\t\t\t\t\tconst path = require('path');\n\t\t\t\t\tconst isDist = path.basename(__dirname) == 'dist';\n\t\t\t\t\tconst typesFile = path.join(__dirname, isDist ? 'paris.d.ts' : 'paris.ts');\n\n\t\t\t\t\tfs.writeFileSync(typesFile, types, 'utf-8');\n\t\t\t\t")}catch(t){console.warn(t)}}))}(),exchange}(),convert=exchangeWrap;convert.default=convert,module.exports&&(module.exports=convert),exports.default=convert},827:function(t,e,r){var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function a(t){try{c(n.next(t))}catch(t){o(t)}}function s(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}c((n=n.apply(t,e||[])).next())}))},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.WorkerReady=void 0;const o=i(r(203)),a=r(382),s="undefined"!=typeof window&&window.document;function c(t={}){this.list={crypto:["BTC","ETH","USDT","XRP","DOT","ADA","LTC","LINK","BCH","BNB","XLM","USDC","UNI","WBTC","DOGE","AAVE","BSV","EOS","XMR","XEM","TRX","XTZ","THETA","SNX","ATOM","VET","SUSHI","DAI","NEO","MKR","COMP","CRO","HT","BUSD","SOL","LEO","MIOTA","FTT","CEL","EGLD","DASH","UMA","AVAX","FIL","ZEC","LUNA","GRT","YFI","KSM","REV","ETC","DCR","ALGO","ZIL","CHSB","WAVES","NEAR","LRC","HBAR","REN","OMG","NEXO","RUNE","RENBTC","VGX","CELO","CRV","1INCH","ZRX","ONT","HEDG","BAT","NANO","HUSD","ICX","BTT","QNT","DGB","SC","TUSD","ZEN","OKB","RSR","ALPHA","QTUM","STX","FTM","AMPL","FUN","KNC","ENJ","IOST","MANA","XVG","UST","OCEAN","BTCB","BNT","PAX","BAND"],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.data={crypto:{last_update:null,current:null},fiat:{last_update:null,current:null}},this.options=Object.assign({crypto_interval:s?1e4:5e3,fiat_interval:36e5,calculateAverage:!0,binance:!0,coinbase:!0,bitfinex:!0,onUpdate:void 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}c.prototype.setOptions=function(t){let e="function"==typeof t?t(Object.assign({},this.options)):t||{};return this.options=Object.assign(Object.assign(Object.assign({},this.options),e),{crypto_interval:isNaN(e.crypto_interval)?this.options.crypto_interval:Math.min(s?5e3:1e3,e.crypto_interval),fiat_interval:isNaN(e.fiat_interval)?this.options.fiat_interval:Math.min(18e5,e.fiat_interval)}),this.data.crypto.current=this.joinPrices(this.data),this},c.prototype.updateCrypto=function(){return n(this,void 0,void 0,(function*(){this.data.crypto.last_updated||this.log("Updating crypto...");const t={binance:o.default.binance.ticker,bitfinex:o.default.bitfinex.ticker,coinbase:o.default.coinbase.ticker};let e=[],r={};for(const n in t)try{this.data.crypto[n]=yield t[n](),this.options[n]&&(e.push(this.data.crypto[n]),r=Object.assign(Object.assign({},r),this.data.crypto[n]),this.data.crypto.last_updated=+new Date)}catch(t){this.data.crypto[n]=null,console.error(`Failed fetching prices from ${n}`,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}))},c.prototype.updateFiat=function(){return n(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}))},c.prototype.updateLists=function(){return n(this,void 0,void 0,(function*(){this.log("Updating top currency list...");try{this.list.crypto=yield o.default.coinmarketcap.top()}catch(t){console.error("Failed fetching fiat prices from ECB",t)}return this}))},c.prototype.joinPrices=function(t){const e={binance:t.crypto.binance,coinbase:t.crypto.coinbase,bitfinex:t.crypto.bitfinex};let r=[],n={};for(const t in e)this.options[t]&&e[t]&&(r.push(e[t]),n=Object.assign(Object.assign({},n),e[t]));return this.options.calculateAverage?Object.assign(Object.assign({},n),(0,a.getAverage)(r)):n},c.prototype.browserTicker=function(){return n(this,void 0,void 0,(function*(){try{const t=yield o.default.coinconvert.ticker();let e=this.joinPrices(t);this.data=Object.assign(Object.assign({},t),{crypto:Object.assign(Object.assign({},t.crypto),{current:e})}),"function"==typeof this.options.onUpdate&&this.options.onUpdate(this.data)}catch(t){console.error("Failed fetching prices from API",t)}return this}))},c.prototype.runBrowser=function(){return n(this,void 0,void 0,(function*(){return yield this.browserTicker(),this.list=yield o.default.coinconvert.list(),this.isReady=!0,this.crypto_worker&&clearInterval,this.crypto_worker=setInterval(this.browserTicker.bind(this),this.options.crypto_interval),this}))},c.prototype.runServer=function(){return n(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}))},c.prototype.run=function(){return this.isRunning=!0,s?this.runBrowser():this.runServer()},c.prototype.stop=function(){return clearInterval(this.crypto_worker),clearInterval(this.fiat_worker),this.isRunning=!1,this},c.prototype.restart=function(){return this.stop().run()};const u=new c;e.WorkerReady=u.run(),e.default=u},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__})()));

@@ -1,310 +0,3 @@

/*!
* Made with Rests
* github.com/el1s7/rests
*/
type json =
| string
| number
| boolean
| null
| json[]
| {[key: string]: json};
interface FormData {
[Symbol.iterator](): IterableIterator<[string, File | string]>;
/** Returns an array of key, value pairs for every entry in the list. */
entries(): IterableIterator<[string, File | string]>;
/** Returns a list of keys in the list. */
keys(): IterableIterator<string>;
/** Returns a list of values in the list. */
values(): IterableIterator<File | string>;
}
interface ResponseObject {
statusCode: number,
statusText: string,
headers: Headers,
type: "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect" ,
ok: boolean,
json?: any,
text?: string,
formData?: FormData,
blob?: Blob,
message?: string
}
type HookRequest = {
/**
* Fetch URL
*/
url: string,
/**
* Fetch Options
*/
options: any,
/**
* The parameters supplied for this request
*/
params: any
/**
* Rests instance
*/
instance: any
/**
* Endpoint Key, e.g "user.login"
*/
key: string
};
interface Hooks {
/**
* A global hook function that is called on request.
*
*/
on_request?: (request: HookRequest) => any,
/**
* A hook function that is called on successful response, you can also modify and return a different response.
*/
on_success?: (response: ResponseObject, request?: HookRequest) => any,
/**
* A hook function that is called on errors.
*
*
* To return a different error:
*/
on_error?: (error: ResponseObject | unknown, request?: HookRequest) => any,
}
interface Params {
[name: string]:{
/** The parameter HTTP name */
name?: string,
/** Required or not */
required?: boolean,
/** A help message to throw in case of errors */
help?: string,
/** Param type (default: any)*/
type?: "string" | "number" | "array" | "object" | "boolean" | "any",
/** Example value */
example?: any,
/** Format functions that accepts supplied value and returns formatted value. */
format?: (value: any)=>any,
/** Regex validation */
validate?: RegExp | string,
/** Array validation */
in?: any[],
max?: number,
min?: number,
/** Default value */
default?: any,
/** HTTP Location */
location?: "body" | "headers" | "query" | "path",
}
}
interface Options extends Hooks {
base?: string,
sandboxBase?: string,
headers?: any,
params?: Params,
/**
* Set default values for parameters
*/
values?: {
[param_name: string]: any
}
/**
* Node-Fetch option for adding a proxy
*/
fetch_agent?: any,
}
interface newCategoryOptions {
/**
* Override global options for this category
*/
$options: Options;
}
interface newCategoryWithOptions extends newCategoryOptions {
[param: string]: any | Options;
}
type newCategoryValues = {
[param: string]: any
} | newCategoryWithOptions;
declare class HideFuncProps<T>{
private name;
private apply;
private bind;
private arguments;
private call;
private caller;
private length;
private prototype;
private toString;
//public set: (values: newCategoryValues) => T;
}
interface updateOptions<X> extends HideFuncProps<X>{
set: (values: newCategoryValues) => X
}
interface newCategory<T> extends HideFuncProps<T> {
new(values: newCategoryValues): T & updateOptions<T>;
}
export interface APIBinance extends newCategory<APIBinance> {
/**
* Ticker - GET request
*/
ticker: () => Promise<ResponseObject>;
}
export interface APIBitfinex extends newCategory<APIBitfinex> {
/**
* Ticker - GET request
*/
ticker: (params?: {
/**
* The symbols you want information about as a comma separated list, or ALL for every symbol. (Examples of possible symbols: tBTCUSD, tETHUSD, fUSD, fBTC)
*
* @example
*
* `"ALL"`
*
*/
symbols?: string
} | FormData) => Promise<ResponseObject>;
}
export interface APICoinbase extends newCategory<APICoinbase> {
/**
* Ticker - GET request
*/
ticker: (params?: {
/**
* The exchange currency (default USD)
*/
currency?: any
} | FormData) => Promise<ResponseObject>;
}
export interface APICoinmarketcap extends newCategory<APICoinmarketcap> {
/**
* Top - GET request
*/
top: (params?: {
/**
*
*
* @example
*
* `"100"`
*
*/
limit?: number
} | FormData) => Promise<ResponseObject>;
}
export interface APIFiat extends newCategory<APIFiat> {
/**
* All - GET request
*/
all: () => Promise<ResponseObject>;
}
export interface APICoinconvert extends newCategory<APICoinconvert> {
/**
* Ticker - GET request
*/
ticker: () => Promise<ResponseObject>;
/**
* List - GET request
*/
list: () => Promise<ResponseObject>;
}
export interface API extends updateOptions<API> {
/**
* Binance Endpoints Category
*/
binance: APIBinance
/**
* Bitfinex Endpoints Category
*/
bitfinex: APIBitfinex
/**
* Coinbase Endpoints Category
*/
coinbase: APICoinbase
/**
* Coinmarketcap Endpoints Category
*/
coinmarketcap: APICoinmarketcap
/**
* Fiat Endpoints Category
*/
fiat: APIFiat
/**
* Coinconvert Endpoints Category
*/
coinconvert: APICoinconvert
}
declare const API: API;
export default API;
import { API as APITypes } from './api.d';
declare const _default: APITypes;
export default _default;

@@ -130,7 +130,7 @@ "use strict";

ticker: {
path: "https://api.coinconvert.net/v2/ticker?v=1.1.2",
path: "https://api.coinconvert.net/v2/ticker?v=1.1.3",
on_success: (response) => (response.json)
},
list: {
path: "https://api.coinconvert.net/list?v=1.1.2",
path: "https://api.coinconvert.net/list?v=1.1.3",
on_success: (response) => (response.json)

@@ -137,0 +137,0 @@ }

@@ -19,2 +19,3 @@ import { Options, PricesClass, Tickers } from "./worker";

};
isReady: boolean;
/**

@@ -37,3 +38,3 @@ * Check if cache has loaded.

* const is_ready = await convert.start();
*
* ```
*/

@@ -40,0 +41,0 @@ start: () => Promise<PricesClass>;

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

};
this.options = Object.assign({ crypto_interval: (5 * 1e3), fiat_interval: (60 * 1e3 * 60), calculateAverage: true, binance: true, coinbase: true, bitfinex: true, onUpdate: undefined }, initialOptions);
this.options = Object.assign({ crypto_interval: isBrowser ? 10 * 1e3 : (5 * 1e3), fiat_interval: (60 * 1e3 * 60), calculateAverage: true, binance: true, coinbase: true, bitfinex: true, onUpdate: undefined }, initialOptions);
this.log = function () {

@@ -57,3 +57,3 @@ var _a, _b;

(o || {});
this.options = Object.assign(Object.assign(Object.assign({}, this.options), newOptions), { crypto_interval: isNaN(newOptions.crypto_interval) ? this.options.crypto_interval : Math.min(1000, newOptions.crypto_interval), fiat_interval: isNaN(newOptions.fiat_interval) ? this.options.fiat_interval : Math.min(5000, newOptions.fiat_interval) });
this.options = Object.assign(Object.assign(Object.assign({}, this.options), newOptions), { crypto_interval: isNaN(newOptions.crypto_interval) ? this.options.crypto_interval : Math.min(isBrowser ? 5000 : 1000, newOptions.crypto_interval), fiat_interval: isNaN(newOptions.fiat_interval) ? this.options.fiat_interval : Math.min(60 * 30 * 1e3, newOptions.fiat_interval) });
//Update current

@@ -60,0 +60,0 @@ this.data.crypto.current = this.joinPrices(this.data);

{
"name": "crypto-convert",
"version": "1.1.2",
"version": "1.1.3",
"description": "Instantly convert cryptocurrency and get price information",

@@ -13,3 +13,3 @@ "main": "dist/index.js",

"type": "git",
"url": "git+https://github.com/elis-k/crypto-convert.git"
"url": "git+https://github.com/coinconvert/crypto-convert.git"
},

@@ -32,3 +32,3 @@ "keywords": [

"bugs": {
"url": "https://github.com/elis-k/crypto-convert/issues"
"url": "https://github.com/coinconvert/crypto-convert/issues"
},

@@ -35,0 +35,0 @@ "homepage": "https://oh.gold",

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

Sorry, the diff of this file is not supported yet

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