@vdegenne/cmc 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,14 +20,18 @@ Create static data from CoinMarketCap :
20
20
 
21
21
  ```ts
22
22
  /* cmc.ts */
23
- import _currencies from '@vdegenne/cmc/data/mini.json?inline' with {type: 'json'}
23
+ import _currencies from '@vdegenne/cmc/data/mini.json' with {type: 'json'}
24
24
  export * from '@vdegenne/cmc'
25
25
 
26
- export const currencies = _currencies as unknown as CMC.MiniCurrency[]
26
+ export const currencies = _currencies as CMC.MiniCurrency[]
27
27
 
28
- export function getCMCCurrencyFromSymbol(symbol: string) {
28
+ export function getCMCCurrencyFromSymbol(symbol: string, fromLast = false) {
29
+ const currencies = [..._currencies] as CMC.MiniCurrency[]
30
+ if (fromLast) {
31
+ currencies.reverse()
32
+ }
29
33
  symbol = symbol.toLocaleUpperCase()
30
- return currencies.find((c) => symbol === c.symbol)
34
+ return currencies.find((c) => c.symbol === symbol)
31
35
  }
32
36
  ```
33
37