@azuro-org/toolkit 0.1.3 → 0.1.4
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.
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type Dictionaries } from '@azuro-org/dictionaries';
|
|
2
|
-
type Outcome = {
|
|
2
|
+
type Outcome<T> = T & {
|
|
3
3
|
conditionId: string;
|
|
4
4
|
outcomeId: string;
|
|
5
5
|
selectionName: string;
|
|
6
6
|
lpAddress: string;
|
|
7
7
|
coreAddress: string;
|
|
8
8
|
};
|
|
9
|
-
type Markets = {
|
|
9
|
+
type Markets<T> = {
|
|
10
10
|
marketName: string;
|
|
11
|
-
outcomes: Outcome[][];
|
|
11
|
+
outcomes: Outcome<T>[][];
|
|
12
12
|
}[];
|
|
13
13
|
type Props = {
|
|
14
14
|
lpAddress: string;
|
|
@@ -26,5 +26,5 @@ type Props = {
|
|
|
26
26
|
}[];
|
|
27
27
|
dictionaries: Dictionaries;
|
|
28
28
|
};
|
|
29
|
-
export default function aggregateOutcomesByMarkets(props: Props): Markets
|
|
29
|
+
export default function aggregateOutcomesByMarkets<T extends {}>(props: Props): Markets<T>;
|
|
30
30
|
export {};
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
|
-
import {getMarketKey,getMarketName,assembleSelectionName}from'@azuro-org/dictionaries'
|
|
1
|
+
import {getMarketKey,getMarketName,assembleSelectionName}from'@azuro-org/dictionaries';/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
|
|
16
|
+
var __assign = function() {
|
|
17
|
+
__assign = Object.assign || function __assign(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function __rest(s, e) {
|
|
28
|
+
var t = {};
|
|
29
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
30
|
+
t[p] = s[p];
|
|
31
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
32
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
33
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
34
|
+
t[p[i]] = s[p[i]];
|
|
35
|
+
}
|
|
36
|
+
return t;
|
|
37
|
+
}function aggregateOutcomesByMarkets(props) {
|
|
2
38
|
var lpAddress = props.lpAddress, conditions = props.conditions, dictionaries = props.dictionaries;
|
|
3
39
|
// group conditions by marketId
|
|
4
40
|
var outcomesByMarketKey = {};
|
|
@@ -6,17 +42,11 @@ import {getMarketKey,getMarketName,assembleSelectionName}from'@azuro-org/diction
|
|
|
6
42
|
conditions.forEach(function (_a) {
|
|
7
43
|
var conditionId = _a.conditionId, outcomes = _a.outcomes, core = _a.core;
|
|
8
44
|
outcomes.forEach(function (_a) {
|
|
9
|
-
var outcomeId = _a.outcomeId;
|
|
45
|
+
var outcomeId = _a.outcomeId, rest = __rest(_a, ["outcomeId"]);
|
|
10
46
|
var marketKey = getMarketKey(outcomeId, dictionaries);
|
|
11
47
|
var marketName = getMarketName(outcomeId, dictionaries);
|
|
12
48
|
var selectionName = assembleSelectionName(outcomeId, dictionaries);
|
|
13
|
-
var outcome = {
|
|
14
|
-
conditionId: conditionId,
|
|
15
|
-
outcomeId: outcomeId,
|
|
16
|
-
selectionName: selectionName,
|
|
17
|
-
lpAddress: lpAddress,
|
|
18
|
-
coreAddress: core.address,
|
|
19
|
-
};
|
|
49
|
+
var outcome = __assign({ conditionId: conditionId, outcomeId: outcomeId, selectionName: selectionName, lpAddress: lpAddress, coreAddress: core.address }, rest);
|
|
20
50
|
// it's important to use "marketKey" because it's unique
|
|
21
51
|
// on other hand "marketId" can be same for different groups of conditions
|
|
22
52
|
// "marketKey" is a string template "marketId-gamePeriodId-gameTypeId[-teamPlayerId]"
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type Dictionaries } from '@azuro-org/dictionaries';
|
|
2
|
-
type Outcome = {
|
|
2
|
+
type Outcome<T> = T & {
|
|
3
3
|
conditionId: string;
|
|
4
4
|
outcomeId: string;
|
|
5
5
|
selectionName: string;
|
|
6
6
|
lpAddress: string;
|
|
7
7
|
coreAddress: string;
|
|
8
8
|
};
|
|
9
|
-
type Markets = {
|
|
9
|
+
type Markets<T> = {
|
|
10
10
|
marketName: string;
|
|
11
|
-
outcomes: Outcome[][];
|
|
11
|
+
outcomes: Outcome<T>[][];
|
|
12
12
|
}[];
|
|
13
13
|
type Props = {
|
|
14
14
|
lpAddress: string;
|
|
@@ -26,5 +26,5 @@ type Props = {
|
|
|
26
26
|
}[];
|
|
27
27
|
dictionaries: Dictionaries;
|
|
28
28
|
};
|
|
29
|
-
export default function aggregateOutcomesByMarkets(props: Props): Markets
|
|
29
|
+
export default function aggregateOutcomesByMarkets<T extends {}>(props: Props): Markets<T>;
|
|
30
30
|
export {};
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var dictionaries=require('@azuro-org/dictionaries')
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var dictionaries=require('@azuro-org/dictionaries');/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
|
|
16
|
+
var __assign = function() {
|
|
17
|
+
__assign = Object.assign || function __assign(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function __rest(s, e) {
|
|
28
|
+
var t = {};
|
|
29
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
30
|
+
t[p] = s[p];
|
|
31
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
32
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
33
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
34
|
+
t[p[i]] = s[p[i]];
|
|
35
|
+
}
|
|
36
|
+
return t;
|
|
37
|
+
}function aggregateOutcomesByMarkets(props) {
|
|
2
38
|
var lpAddress = props.lpAddress, conditions = props.conditions, dictionaries$1 = props.dictionaries;
|
|
3
39
|
// group conditions by marketId
|
|
4
40
|
var outcomesByMarketKey = {};
|
|
@@ -6,17 +42,11 @@
|
|
|
6
42
|
conditions.forEach(function (_a) {
|
|
7
43
|
var conditionId = _a.conditionId, outcomes = _a.outcomes, core = _a.core;
|
|
8
44
|
outcomes.forEach(function (_a) {
|
|
9
|
-
var outcomeId = _a.outcomeId;
|
|
45
|
+
var outcomeId = _a.outcomeId, rest = __rest(_a, ["outcomeId"]);
|
|
10
46
|
var marketKey = dictionaries.getMarketKey(outcomeId, dictionaries$1);
|
|
11
47
|
var marketName = dictionaries.getMarketName(outcomeId, dictionaries$1);
|
|
12
48
|
var selectionName = dictionaries.assembleSelectionName(outcomeId, dictionaries$1);
|
|
13
|
-
var outcome = {
|
|
14
|
-
conditionId: conditionId,
|
|
15
|
-
outcomeId: outcomeId,
|
|
16
|
-
selectionName: selectionName,
|
|
17
|
-
lpAddress: lpAddress,
|
|
18
|
-
coreAddress: core.address,
|
|
19
|
-
};
|
|
49
|
+
var outcome = __assign({ conditionId: conditionId, outcomeId: outcomeId, selectionName: selectionName, lpAddress: lpAddress, coreAddress: core.address }, rest);
|
|
20
50
|
// it's important to use "marketKey" because it's unique
|
|
21
51
|
// on other hand "marketId" can be same for different groups of conditions
|
|
22
52
|
// "marketKey" is a string template "marketId-gamePeriodId-gameTypeId[-teamPlayerId]"
|