@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.
Files changed (54) hide show
  1. package/dist/{competitions.d.ts → lib/competitions.d.ts} +0 -0
  2. package/dist/{competitions.js → lib/competitions.js} +2 -2
  3. package/dist/lib/competitions.js.map +1 -0
  4. package/dist/{countries.d.ts → lib/countries.d.ts} +0 -0
  5. package/dist/{countries.js → lib/countries.js} +0 -0
  6. package/dist/lib/countries.js.map +1 -0
  7. package/dist/{experience.d.ts → lib/experience.d.ts} +3 -2
  8. package/dist/{experience.js → lib/experience.js} +4 -2
  9. package/dist/lib/experience.js.map +1 -0
  10. package/dist/{groups.d.ts → lib/groups.d.ts} +2 -1
  11. package/dist/{groups.js → lib/groups.js} +4 -2
  12. package/dist/lib/groups.js.map +1 -0
  13. package/dist/{index.d.ts → lib/index.d.ts} +0 -0
  14. package/dist/{index.js → lib/index.js} +0 -0
  15. package/dist/lib/index.js.map +1 -0
  16. package/dist/{metrics.d.ts → lib/metrics.d.ts} +796 -128
  17. package/dist/{metrics.js → lib/metrics.js} +18 -17
  18. package/dist/lib/metrics.js.map +1 -0
  19. package/dist/{numbers.d.ts → lib/numbers.d.ts} +0 -0
  20. package/dist/{numbers.js → lib/numbers.js} +0 -0
  21. package/dist/lib/numbers.js.map +1 -0
  22. package/dist/{periods.d.ts → lib/periods.d.ts} +0 -0
  23. package/dist/{periods.js → lib/periods.js} +1 -1
  24. package/dist/lib/periods.js.map +1 -0
  25. package/dist/{players.d.ts → lib/players.d.ts} +0 -0
  26. package/dist/{players.js → lib/players.js} +3 -2
  27. package/dist/lib/players.js.map +1 -0
  28. package/dist/lib/strings.d.ts +3 -0
  29. package/dist/{strings.js → lib/strings.js} +1 -7
  30. package/dist/lib/strings.js.map +1 -0
  31. package/package.json +12 -4
  32. package/.prettierrc +0 -7
  33. package/dist/competitions.js.map +0 -1
  34. package/dist/countries.js.map +0 -1
  35. package/dist/experience.js.map +0 -1
  36. package/dist/groups.js.map +0 -1
  37. package/dist/index.js.map +0 -1
  38. package/dist/metrics.js.map +0 -1
  39. package/dist/numbers.js.map +0 -1
  40. package/dist/periods.js.map +0 -1
  41. package/dist/players.js.map +0 -1
  42. package/dist/strings.d.ts +0 -3
  43. package/dist/strings.js.map +0 -1
  44. package/src/competitions.ts +0 -54
  45. package/src/countries.ts +0 -275
  46. package/src/experience.ts +0 -77
  47. package/src/groups.ts +0 -555
  48. package/src/index.ts +0 -9
  49. package/src/metrics.ts +0 -629
  50. package/src/numbers.ts +0 -5
  51. package/src/periods.ts +0 -67
  52. package/src/players.ts +0 -76
  53. package/src/strings.ts +0 -34
  54. 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
- }