npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

crypto-symbol

v3.6.0

Published

Provide easy conversion between crypto symbol and name

Downloads

1,319

Readme

🐤 Simple fuzzy conversion for crypto symbol and crypto name.

📔 Source: CoinMarketCap

🔔 Almost 5000 pairs to search for, with typescript const assertion.

💪 Can add your own custom name-symbol pair.

🌟 Optimized lookup time.

🆙 Check for update daily and publish new version if there is change.

🥰 0 dependencies.

⛲️ Out of box typescript support.

🦺 Development code, built code, and published code are all tested in CI.

Installation

npm i crypto-symbol

Usage

Normally ticker symbol is unique, but for whatever reason on very rare occasional, CMC lists new coin that has the same ticker symbol(case-insensitive). If duplicated names or symbols are found in the CoinMarketCap list, the library keep higher rank(larger market cap) coins. If you need lower rank coins, please can add it yourself. Keep in mind to use unique name and unique symbol for them.

🎵 Get Pairs Object

import { cryptoSymbol } from 'crypto-symbol'

const { get } = cryptoSymbol({})

// all the pair objects are properly typed with const assertion
get().NSPair // {Bitcoin: 'BTC',Ethereum: 'ETH','Binance Coin': 'BNB',......}
get().SNPair // {BTC: 'Bitcoin',ETH: 'Ethereum','BNB': 'Binance Coin',......}

⚒ Add new pair or modify existing pair

import { cryptoSymbol } from 'crypto-symbol'

// will overwrite existing pair and add new type to pairs object
const { get, nameLookup, symbolLookup } = cryptoSymbol({
	newCoin: 'NC123' as const, // add new coin
	bitcoin: 'BTC' as const, // modify existing coin
}) // use const assertion to narrow down the type

🎐 Symbol Lookup

import { cryptoSymbol } from 'crypto-symbol'

const { symbolLookup } = cryptoSymbol({})

// case insensitive
// ignore all special character and space
symbolLookup('  liT ec @oin  ') // "LTC"
symbolLookup(' τbITcO in ') // BTC

// case insensitive
// can allow specific special character
// to allow multiple special character, simply concat all the character, eg "#$%)("
symbolLookup(' τbITcO in ', { allow: 'τ' }) // TBTC

// exact match (case sensitive)
symbolLookup('  liT ec @oin  ', { exact: true }) // undefined
symbolLookup('litecoin', { exact: true }) // "undefined"
symbolLookup('Litecoin', { exact: true }) // "LTC"

⚡️ Name Lookup

import { cryptoSymbol } from 'crypto-symbol'

const { nameLookup } = cryptoSymbol({})

// case insensitive
// ignore all special character and space)
nameLookup('  @Ltc!   ') // "Litecoin"

// can allow specific special character
// to allow multiple special character, simply concat all the character, eg "#$%)("
// all symbol are alphanumeric anyway, I don't think you will need it
nameLookup('  @Ltc!   ', { allow: '@' }) // undefined, because symbol "@Ltc" does not exist

// exact match (case sensitive)
nameLookup('  Ltc   ', { exact: true }) // undefined
nameLookup('Ltc', { exact: true }) // undefined
nameLookup('LTC', { exact: true }) // Litecoin

🍀 Sync

Sync the coin manually.

  1. You can only use this api in server environment due to Coinmarketcap CORS policy.
  2. You need to install axios to use this api, simply installing it is enough.
npm i axios
  1. Added pairs and modified pairs have higher priority than sync, sync will not overwrite them.
import { cryptoSymbol } from 'crypto-symbol'

const { sync } = cryptoSymbol({})

// sync with latest coinmarketcap list
// this is a promise
sync('coinmarketcap apiKey')

Credit

Crypto Symbol logo source