@wise-old-man/utils 1.0.8 → 1.0.12
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.
- package/dist/{competitions.d.ts → lib/competitions.d.ts} +0 -0
- package/dist/{competitions.js → lib/competitions.js} +2 -2
- package/dist/lib/competitions.js.map +1 -0
- package/dist/{countries.d.ts → lib/countries.d.ts} +0 -0
- package/dist/{countries.js → lib/countries.js} +0 -0
- package/dist/lib/countries.js.map +1 -0
- package/dist/{experience.d.ts → lib/experience.d.ts} +3 -2
- package/dist/{experience.js → lib/experience.js} +4 -2
- package/dist/lib/experience.js.map +1 -0
- package/dist/{groups.d.ts → lib/groups.d.ts} +2 -1
- package/dist/{groups.js → lib/groups.js} +4 -2
- package/dist/lib/groups.js.map +1 -0
- package/dist/{index.d.ts → lib/index.d.ts} +0 -0
- package/dist/{index.js → lib/index.js} +0 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/{metrics.d.ts → lib/metrics.d.ts} +796 -128
- package/dist/{metrics.js → lib/metrics.js} +18 -17
- package/dist/lib/metrics.js.map +1 -0
- package/dist/{numbers.d.ts → lib/numbers.d.ts} +0 -0
- package/dist/{numbers.js → lib/numbers.js} +0 -0
- package/dist/lib/numbers.js.map +1 -0
- package/dist/{periods.d.ts → lib/periods.d.ts} +0 -0
- package/dist/{periods.js → lib/periods.js} +1 -1
- package/dist/lib/periods.js.map +1 -0
- package/dist/{players.d.ts → lib/players.d.ts} +0 -0
- package/dist/{players.js → lib/players.js} +3 -2
- package/dist/lib/players.js.map +1 -0
- package/dist/lib/strings.d.ts +3 -0
- package/dist/{strings.js → lib/strings.js} +1 -7
- package/dist/lib/strings.js.map +1 -0
- package/package.json +12 -4
- package/.prettierrc +0 -7
- package/dist/competitions.js.map +0 -1
- package/dist/countries.js.map +0 -1
- package/dist/experience.js.map +0 -1
- package/dist/groups.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/metrics.js.map +0 -1
- package/dist/numbers.js.map +0 -1
- package/dist/periods.js.map +0 -1
- package/dist/players.js.map +0 -1
- package/dist/strings.d.ts +0 -3
- package/dist/strings.js.map +0 -1
- package/src/competitions.ts +0 -54
- package/src/countries.ts +0 -275
- package/src/experience.ts +0 -77
- package/src/groups.ts +0 -555
- package/src/index.ts +0 -9
- package/src/metrics.ts +0 -629
- package/src/numbers.ts +0 -5
- package/src/periods.ts +0 -67
- package/src/players.ts +0 -76
- package/src/strings.ts +0 -34
- package/tsconfig.json +0 -16
package/src/players.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
enum PlayerType {
|
|
2
|
-
UNKNOWN = 'unknown',
|
|
3
|
-
REGULAR = 'regular',
|
|
4
|
-
IRONMAN = 'ironman',
|
|
5
|
-
HARDCORE = 'hardcore',
|
|
6
|
-
ULTIMATE = 'ultimate'
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
enum PlayerBuild {
|
|
10
|
-
MAIN = 'main',
|
|
11
|
-
F2P = 'f2p',
|
|
12
|
-
LVL3 = 'lvl3',
|
|
13
|
-
ZERKER = 'zerker',
|
|
14
|
-
DEF1 = '1def',
|
|
15
|
-
HP10 = '10hp'
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const PlayerTypeProps = {
|
|
19
|
-
[PlayerType.UNKNOWN]: { name: 'Unknown' },
|
|
20
|
-
[PlayerType.REGULAR]: { name: 'Regular' },
|
|
21
|
-
[PlayerType.IRONMAN]: { name: 'Ironman' },
|
|
22
|
-
[PlayerType.HARDCORE]: { name: 'Hardcore' },
|
|
23
|
-
[PlayerType.ULTIMATE]: { name: 'Ultimate' }
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const PlayerBuildProps = {
|
|
27
|
-
[PlayerBuild.MAIN]: { name: 'Main' },
|
|
28
|
-
[PlayerBuild.F2P]: { name: 'F2P' },
|
|
29
|
-
[PlayerBuild.LVL3]: { name: 'Level 3' },
|
|
30
|
-
[PlayerBuild.ZERKER]: { name: 'Zerker Pure' },
|
|
31
|
-
[PlayerBuild.DEF1]: { name: '1 Defence Pure' },
|
|
32
|
-
[PlayerBuild.HP10]: { name: '10 Hitpoints Pure' }
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const PLAYER_TYPES = Object.values(PlayerType);
|
|
36
|
-
const PLAYER_BUILDS = Object.values(PlayerBuild);
|
|
37
|
-
|
|
38
|
-
function findPlayerType(typeName: string): PlayerType | null {
|
|
39
|
-
for (var [key, value] of Object.entries(PlayerTypeProps)) {
|
|
40
|
-
if (value.name === typeName) return key as PlayerType;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function findPlayerBuild(buildName: string): PlayerBuild | null {
|
|
47
|
-
for (var [key, value] of Object.entries(PlayerBuildProps)) {
|
|
48
|
-
if (value.name === buildName) return key as PlayerBuild;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function standardizeUsername(username) {
|
|
55
|
-
return sanitizeUsername(username).toLowerCase();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function sanitizeUsername(username) {
|
|
59
|
-
return username.replace(/[-_\s]/g, ' ').trim();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export {
|
|
63
|
-
// Enums
|
|
64
|
-
PlayerType,
|
|
65
|
-
PlayerBuild,
|
|
66
|
-
PlayerTypeProps,
|
|
67
|
-
PlayerBuildProps,
|
|
68
|
-
// Lists
|
|
69
|
-
PLAYER_TYPES,
|
|
70
|
-
PLAYER_BUILDS,
|
|
71
|
-
// Functions
|
|
72
|
-
findPlayerType,
|
|
73
|
-
findPlayerBuild,
|
|
74
|
-
sanitizeUsername,
|
|
75
|
-
standardizeUsername
|
|
76
|
-
};
|
package/src/strings.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export function capitalize(string: string | null): string | null {
|
|
2
|
-
if (!string) return null;
|
|
3
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export function formatNumber(num: number, withLetters = false) {
|
|
7
|
-
if (num === undefined || num === null) return -1;
|
|
8
|
-
|
|
9
|
-
// If number is float
|
|
10
|
-
if (num % 1 !== 0) {
|
|
11
|
-
return (Math.round(num * 100) / 100).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if ((num < 10000 && num > -10000) || !withLetters) {
|
|
15
|
-
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// < 10 million
|
|
19
|
-
if (num < 10_000_000 && num > -10_000_000) {
|
|
20
|
-
return `${Math.floor(num / 1000)}k`;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// < 1 billion
|
|
24
|
-
if (num < 1_000_000_000 && num > -1_000_000_000) {
|
|
25
|
-
return `${Math.round((num / 1000000 + Number.EPSILON) * 100) / 100}m`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return `${Math.round((num / 1000000000 + Number.EPSILON) * 100) / 100}b`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function padNumber(value: number): string {
|
|
32
|
-
if (!value) return '00';
|
|
33
|
-
return value < 10 ? `0${value}` : value.toString();
|
|
34
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"lib": ["es6", "dom", "es2017"],
|
|
4
|
-
"target": "es5",
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"noImplicitAny": false,
|
|
8
|
-
"forceConsistentCasingInFileNames": true,
|
|
9
|
-
"strict": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"outDir": "dist",
|
|
12
|
-
"sourceMap": true,
|
|
13
|
-
"declaration": true
|
|
14
|
-
},
|
|
15
|
-
"exclude": ["node_modules", "dist"]
|
|
16
|
-
}
|