New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@azuro-org/toolkit

Package Overview
Dependencies
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azuro-org/toolkit - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

11

dist/aggregateOutcomesByMarkets.d.ts

@@ -9,6 +9,6 @@ import { type Dictionaries } from '@azuro-org/dictionaries';

};
type Markets<T> = {
type FinalMarket<T> = {
marketName: string;
outcomes: Outcome<T>[][];
}[];
};
type Props = {

@@ -19,2 +19,3 @@ lpAddress: string;

conditionId: string;
coreAddress: string;
outcomes: {

@@ -24,10 +25,6 @@ [key: string]: any;

}[];
core: {
[key: string]: any;
address: string;
};
}[];
dictionaries: Dictionaries;
};
export default function aggregateOutcomesByMarkets<T extends {}>(props: Props): Markets<T>;
export default function aggregateOutcomesByMarkets<T extends {}>(props: Props): FinalMarket<T>[];
export {};

@@ -39,19 +39,15 @@ import {getMarketKey,getMarketName,assembleSelectionName}from'@azuro-org/dictionaries';/******************************************************************************

var lpAddress = props.lpAddress, conditions = props.conditions, dictionaries = props.dictionaries;
// group conditions by marketId
var outcomesByMarketKey = {};
var result = {};
var marketsMap = {};
conditions.forEach(function (_a) {
var conditionId = _a.conditionId, outcomes = _a.outcomes, core = _a.core;
var conditionId = _a.conditionId, outcomes = _a.outcomes, coreAddress = _a.coreAddress;
outcomes.forEach(function (_a) {
var outcomeId = _a.outcomeId, rest = __rest(_a, ["outcomeId"]);
// we are using the same key format that was discussed earlier
var marketKey = getMarketKey(outcomeId, dictionaries);
// we are obtaining the human-readable names of each market and the corresponding outcome selections
var marketName = getMarketName(outcomeId, dictionaries);
var selectionName = assembleSelectionName(outcomeId, dictionaries);
var outcome = __assign({ conditionId: conditionId, outcomeId: outcomeId, selectionName: selectionName, lpAddress: lpAddress, coreAddress: core.address }, rest);
// it's important to use "marketKey" because it's unique
// on other hand "marketId" can be same for different groups of conditions
// "marketKey" is a string template "marketId-gamePeriodId-gameTypeId[-teamPlayerId]"
if (!outcomesByMarketKey[marketKey]) {
outcomesByMarketKey[marketKey] = [];
result[marketKey] = {
var outcome = __assign({ conditionId: conditionId, outcomeId: outcomeId, lpAddress: lpAddress, coreAddress: coreAddress, selectionName: selectionName }, rest);
if (!marketsMap[marketKey]) {
marketsMap[marketKey] = {
marketName: marketName,

@@ -61,11 +57,14 @@ outcomes: [],

}
outcomesByMarketKey[marketKey].push(outcome);
marketsMap[marketKey].outcomes.push(outcome);
});
});
var finalMarketsMap = {};
// sort by outcomeId and group by conditionId
Object.keys(outcomesByMarketKey).forEach(function (marketKey) {
var marketId = +marketKey.split('-')[0];
// get outcomes related to the market
var outcomes = outcomesByMarketKey[marketKey];
// sort the conditions by selectionId (outcome)
Object.keys(marketsMap).forEach(function (marketKey) {
var _a = marketsMap[marketKey], marketName = _a.marketName, outcomes = _a.outcomes;
finalMarketsMap[marketKey] = {
marketName: marketName,
outcomes: null,
};
// sort the outcomes by `selectionId` (outcome's selection reference)
outcomes.sort(function (a, b) {

@@ -76,13 +75,15 @@ var left = dictionaries.outcomes[a.outcomeId].selectionId;

});
// markets with different conditionIds and not require additional grouping or sorting
var marketsWithDifferentConditionIds = [1, 2];
if (marketsWithDifferentConditionIds.includes(marketId)) {
result[marketKey].outcomes = [outcomes];
// "Full Time Result" and "Double Chance" are the markets whose outcomes don't require sorting
var MARKETS_THAT_DONT_NEED_GROUPING = [1, 2];
var marketId = marketKey.split('-')[0];
if (MARKETS_THAT_DONT_NEED_GROUPING.includes(+marketId)) {
// it's worth noting that the outcomes are wrapped within an array here due to the "rows" that are presented below
finalMarketsMap[marketKey].outcomes = [outcomes];
}
// group by conditionId to allow draw outcomes by rows in UI, e.g.
//
// Team 1 - Total Goals:
// Over (1.5) Under (1.5)
// Over (0.5) Under (0.5)
else {
// group the outcomes by condition ID, which will allow us to display the draw outcomes in separate rows
//
// Handicap:
// H1 (-0.5) H2 (0.5)
// H1 (0.5) H2 (-0.5)
var outcomesByConditionId_1 = {};

@@ -96,4 +97,4 @@ outcomes.forEach(function (outcome) {

});
var outcomesArr = Object.values(outcomesByConditionId_1);
result[marketKey].outcomes = outcomesArr.sort(function (a, b) {
var rows = Object.values(outcomesByConditionId_1);
finalMarketsMap[marketKey].outcomes = rows.sort(function (a, b) {
var aSum = a.reduce(function (acc, _a) {

@@ -111,3 +112,3 @@ var outcomeId = _a.outcomeId;

});
return Object.values(result);
return Object.values(finalMarketsMap);
}export{aggregateOutcomesByMarkets};

@@ -9,6 +9,6 @@ import { type Dictionaries } from '@azuro-org/dictionaries';

};
type Markets<T> = {
type FinalMarket<T> = {
marketName: string;
outcomes: Outcome<T>[][];
}[];
};
type Props = {

@@ -19,2 +19,3 @@ lpAddress: string;

conditionId: string;
coreAddress: string;
outcomes: {

@@ -24,10 +25,6 @@ [key: string]: any;

}[];
core: {
[key: string]: any;
address: string;
};
}[];
dictionaries: Dictionaries;
};
export default function aggregateOutcomesByMarkets<T extends {}>(props: Props): Markets<T>;
export default function aggregateOutcomesByMarkets<T extends {}>(props: Props): FinalMarket<T>[];
export {};

@@ -39,19 +39,15 @@ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var dictionaries=require('@azuro-org/dictionaries');/******************************************************************************

var lpAddress = props.lpAddress, conditions = props.conditions, dictionaries$1 = props.dictionaries;
// group conditions by marketId
var outcomesByMarketKey = {};
var result = {};
var marketsMap = {};
conditions.forEach(function (_a) {
var conditionId = _a.conditionId, outcomes = _a.outcomes, core = _a.core;
var conditionId = _a.conditionId, outcomes = _a.outcomes, coreAddress = _a.coreAddress;
outcomes.forEach(function (_a) {
var outcomeId = _a.outcomeId, rest = __rest(_a, ["outcomeId"]);
// we are using the same key format that was discussed earlier
var marketKey = dictionaries.getMarketKey(outcomeId, dictionaries$1);
// we are obtaining the human-readable names of each market and the corresponding outcome selections
var marketName = dictionaries.getMarketName(outcomeId, dictionaries$1);
var selectionName = dictionaries.assembleSelectionName(outcomeId, dictionaries$1);
var outcome = __assign({ conditionId: conditionId, outcomeId: outcomeId, selectionName: selectionName, lpAddress: lpAddress, coreAddress: core.address }, rest);
// it's important to use "marketKey" because it's unique
// on other hand "marketId" can be same for different groups of conditions
// "marketKey" is a string template "marketId-gamePeriodId-gameTypeId[-teamPlayerId]"
if (!outcomesByMarketKey[marketKey]) {
outcomesByMarketKey[marketKey] = [];
result[marketKey] = {
var outcome = __assign({ conditionId: conditionId, outcomeId: outcomeId, lpAddress: lpAddress, coreAddress: coreAddress, selectionName: selectionName }, rest);
if (!marketsMap[marketKey]) {
marketsMap[marketKey] = {
marketName: marketName,

@@ -61,11 +57,14 @@ outcomes: [],

}
outcomesByMarketKey[marketKey].push(outcome);
marketsMap[marketKey].outcomes.push(outcome);
});
});
var finalMarketsMap = {};
// sort by outcomeId and group by conditionId
Object.keys(outcomesByMarketKey).forEach(function (marketKey) {
var marketId = +marketKey.split('-')[0];
// get outcomes related to the market
var outcomes = outcomesByMarketKey[marketKey];
// sort the conditions by selectionId (outcome)
Object.keys(marketsMap).forEach(function (marketKey) {
var _a = marketsMap[marketKey], marketName = _a.marketName, outcomes = _a.outcomes;
finalMarketsMap[marketKey] = {
marketName: marketName,
outcomes: null,
};
// sort the outcomes by `selectionId` (outcome's selection reference)
outcomes.sort(function (a, b) {

@@ -76,13 +75,15 @@ var left = dictionaries$1.outcomes[a.outcomeId].selectionId;

});
// markets with different conditionIds and not require additional grouping or sorting
var marketsWithDifferentConditionIds = [1, 2];
if (marketsWithDifferentConditionIds.includes(marketId)) {
result[marketKey].outcomes = [outcomes];
// "Full Time Result" and "Double Chance" are the markets whose outcomes don't require sorting
var MARKETS_THAT_DONT_NEED_GROUPING = [1, 2];
var marketId = marketKey.split('-')[0];
if (MARKETS_THAT_DONT_NEED_GROUPING.includes(+marketId)) {
// it's worth noting that the outcomes are wrapped within an array here due to the "rows" that are presented below
finalMarketsMap[marketKey].outcomes = [outcomes];
}
// group by conditionId to allow draw outcomes by rows in UI, e.g.
//
// Team 1 - Total Goals:
// Over (1.5) Under (1.5)
// Over (0.5) Under (0.5)
else {
// group the outcomes by condition ID, which will allow us to display the draw outcomes in separate rows
//
// Handicap:
// H1 (-0.5) H2 (0.5)
// H1 (0.5) H2 (-0.5)
var outcomesByConditionId_1 = {};

@@ -96,4 +97,4 @@ outcomes.forEach(function (outcome) {

});
var outcomesArr = Object.values(outcomesByConditionId_1);
result[marketKey].outcomes = outcomesArr.sort(function (a, b) {
var rows = Object.values(outcomesByConditionId_1);
finalMarketsMap[marketKey].outcomes = rows.sort(function (a, b) {
var aSum = a.reduce(function (acc, _a) {

@@ -111,3 +112,3 @@ var outcomeId = _a.outcomeId;

});
return Object.values(result);
return Object.values(finalMarketsMap);
}exports.aggregateOutcomesByMarkets=aggregateOutcomesByMarkets;
{
"name": "@azuro-org/toolkit",
"version": "0.1.4",
"version": "0.1.5",
"description": "Set of helpers to work with Azuro protocol",

@@ -5,0 +5,0 @@ "module": "dist/index.es.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc