Socket
Book a DemoInstallSign in
Socket

@azuro-org/dictionaries

Package Overview
Dependencies
Maintainers
3
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azuro-org/dictionaries

CLI and set of helpers to work with Azuro protocol dictionaries

1.0.1
Source
npmnpm
Version published
Maintainers
3
Created
Source

Dictionaries Package

This package provides 2 features: CLI to download dictionaries; helpers to work with dictionaries.

Installation

npm i --save @azuro-org/dictionaries

CLI

All dictionaries stored in public repository. For ease of use, the dictionaries have a version and file format.

It's easy to download dictionary files with CLI. In your package.json add script:

"scripts": {
  "get-dicts": "dictionaries -o {OUTPUT_DIR} -v {VERSION} -t {FILES_TYPE}"
}
  • VERSION is the version of downloaded dictionaries. Find the version you need here.
  • OUTPUT_DIR is the directory where to put downloaded files.
  • FILES_TYPE is the extension of downloaded files. Accepts ts, js, maps, arrays. maps and arrays are json files with different output format.
@azuro-org/dictionaries -o ./dist -v 2.0.0 -t ts # will download v2.0.0 typescript files to ./dist directory

Helpers

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

Get market name and description

import { getMarketKey } from '@azuro-org/dictionaries'
import dictionaries from './path-to-downloaded-dictionaries'

const outcomeId = 1
const marketKey = getMarketKey(outcomeId, dictionaries)

getMarketKey(outcomeId, dictionaries) returns the string key marketId-gamePeriodId-gameTypeId[-teamPlayerId] built from the dictionaries related to passed outcomeId.

In the example above the result is 1-1-1.

There are two dictionary files marketNames.js and marketDescriptions.js. marketKey is used to receive market name and description for specific outcome ID.

import dictionaries from './path-to-downloaded-dictionaries'

dictionaries.marketNames['1-1-1'] // "Full Time Result" 
dictionaries.marketDescriptions['1-1-1'] // "You predict the result..."

!!! Note that there are no texts for each outcomeId !!!

marketNames[marketKey] and marketDescriptions[marketKey] may return undefined. For marketName generation there is other helper assembleMarketName. It generates human readable market name based on outcome marketId, gamePeriodId, gameTypeId, teamPlayerId.

import { getMarketKey, assembleMarketName } from '@azuro-org/dictionaries'
import dictionaries from './path-to-downloaded-dictionaries'

const outcomeId = 42
const marketKey = getMarketKey(outcomeId, dictionaries)

let marketName = dictionaries[marketKey] // undefined

if (!marketName) {
  marketName = assembleMarketName(outcomeId, dictionaries) // "Whole game - Winner of match Goal"
}

There are additional 2 sugar helpers:

import { getMarketName } from '@azuro-org/dictionaries'
import dictionaries from './path-to-downloaded-dictionaries'

getMarketName(1, dictionaries) // "Full Time Result"
getMarketName(42, dictionaries) // "Whole game - Winner of match Goal"
import { getMarketDescription } from '@azuro-org/dictionaries'
import dictionaries from './path-to-downloaded-dictionaries'

getMarketDescription(1, dictionaries) // "You predict the result..."
getMarketDescription(42, dictionaries) // undefined. Note that there is no `assemblyMarketDescription` helper.

Get selection (outcome) name

import { assembleSelectionName } from '@azuro-org/dictionaries'
import dictionaries from './dist'

const outcomeId = 1
const selectionName = assembleSelectionName(outcomeId, dictionaries) // "Yes"

const outcomeId = 4
const selectionName = assembleSelectionName(outcomeId, dictionaries) // "Team 2 (4.5)"

Keywords

dictionaries

FAQs

Package last updated on 28 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.