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

@azuro-org/dictionaries

v3.0.21

Published

CLI and set of helpers to work with Azuro protocol dictionaries

Downloads

2,197

Readme

Dictionaries Package

The Azuro Dictionaries package is designed to provide easy access to the Azuro Protocol dictionaries, which contain mappings between IDs and human-readable strings. The package includes CLI and helpers to make it easy to work with these dictionaries in your project.

Installation

npm install @azuro-org/dictionaries

Helpers

To use the package in your project, you can import the desired helpers from the package:

import { getMarketKey, getMarketName, getMarketDescription, getSelectionName } from '@azuro-org/dictionaries'

The package provides the following helpers:

getMarketKey

Returns a market key - a combination of IDs including the marketId, gamePeriodId, gameTypeId, and teamPlayerId (if applicable). This key is required to get markets name and description from dictionaries.

getMarketKey(outcomeId: string | number): string
const outcomeId = 1

getMarketKey(outcomeId) // "1-1-1"

getMarketName

Returns the human-readable name of the market related to an outcomeId or a marketKey.

getMarketName(props: OneOf<{ marketKey: string, outcomeId: string | number }>): string
getMarketName({ outcomeId: 1 }) // "Full Time Result"
getMarketName({ marketKey: '1-1-1' }) // "Full Time Result"

getMarketDescription

Returns the human-readable description of the market related to an outcomeId or a marketKey.

getMarketDescription(props: OneOf<{ marketKey: string, outcomeId: string | number }>): string
getMarketDescription({ outcomeId: 1 }) // "You predict the result..."
getMarketDescription({ marketKey: '1-1-1' }) // "You predict the result..."

It's important to note that not all outcomeId values have a corresponding market name or description. If the name doesn't exist in the dictionaries, the helper function will return a concatenated string of values taken from the marketId, gamePeriodId, gameTypeId, and teamPlayerId IDs.

In cases where there is no market name for the provided outcomeId, the helper function will return undefined. It's important to keep this in mind when using these helper functions to avoid any unexpected behavior.

getMarketName({ outcomeId: 42 }) // "Whole game - Winner of match Goal"
getMarketDescription({ outcomeId: 42 }) // undefined

getSelectionName

Returns the human-readable name of the selection related to an outcomeId.

getSelectionName(props: OneOf<{ outcomeId: string | number, withPoint?: boolean }>): string
getSelectionName({ outcomeId: 1 }) // "Yes"
getSelectionName({ outcomeId: 4 }) // "Team 2"
getSelectionName({ outcomeId: 4, withPoint: true }) // "Team 2 (4.5)"

Example Usage

import { getMarketName, getMarketDescription, getSelectionName } from '@azuro-org/dictionaries'

const marketName = getMarketName({ outcomeId: 123 })
const marketDescription = getMarketDescription({ outcomeId: 123 })
const selectionName = getSelectionName({ outcomeId: 123 })

CLI

CLI get-outcomes

If you need to get a list of outcomeIds related to a specific market name, you can use the get-outcomes command. For example:

get-outcomes --market 'Full Time Result'

This will return an array of outcomeIds that are related to the specified market.

You can use this list to filter conditions in a GraphQL query, like this:

query Games($filterConditions: Condition_Filter!) {
  games {
    conditions(where: $filterConditions) {
      conditionId
      core {
        address
      }
      outcomes {
        outcomeId
        odds
      }
    }
  }
}
const outcomeIds = [ '29', '30', '31', '6983', '6984' ] // taken from the result of the command execution

useQuery(GAMES_QUERY, {
  variables: {
    filterConditions: {
      outcomes_: {
        outcomeId_in: outcomeIds
      }
    }
  }
})