warframe-worldstate-data 3.1.11 → 3.1.13

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 (260) hide show
  1. package/dist/tools/utilities.d.mts +10 -1
  2. package/dist/tools/utilities.mjs +15 -1
  3. package/package.json +2 -2
  4. package/.commitlintrc.mjs +0 -6
  5. package/.husky/commit-msg +0 -1
  6. package/.husky/pre-commit +0 -1
  7. package/.lintstagedrc.yml +0 -12
  8. package/.mocharc.yml +0 -7
  9. package/.nvmrc +0 -1
  10. package/.nycrc.json +0 -7
  11. package/babel.config.json +0 -4
  12. package/biome.json +0 -51
  13. package/data/arcanes.json +0 -461
  14. package/data/archonShards.json +0 -224
  15. package/data/conclaveData.json +0 -425
  16. package/data/cs/arcanes.json +0 -461
  17. package/data/cs/archonShards.json +0 -224
  18. package/data/cs/conclaveData.json +0 -425
  19. package/data/cs/eventsData.json +0 -27
  20. package/data/cs/factionsData.json +0 -32
  21. package/data/cs/fissureModifiers.json +0 -26
  22. package/data/cs/languages.json +0 -19595
  23. package/data/cs/missionTypes.json +0 -80
  24. package/data/cs/operationTypes.json +0 -6
  25. package/data/cs/persistentEnemyData.json +0 -21
  26. package/data/cs/solNodes.json +0 -2242
  27. package/data/cs/sortieData.json +0 -4253
  28. package/data/cs/steelPath.json +0 -114
  29. package/data/cs/syndicatesData.json +0 -86
  30. package/data/cs/synthTargets.json +0 -1262
  31. package/data/cs/tutorials.json +0 -17
  32. package/data/cs/upgradeTypes.json +0 -14
  33. package/data/de/arcanes.json +0 -461
  34. package/data/de/archonShards.json +0 -224
  35. package/data/de/conclaveData.json +0 -425
  36. package/data/de/eventsData.json +0 -27
  37. package/data/de/factionsData.json +0 -32
  38. package/data/de/fissureModifiers.json +0 -26
  39. package/data/de/languages.json +0 -19595
  40. package/data/de/missionTypes.json +0 -80
  41. package/data/de/operationTypes.json +0 -6
  42. package/data/de/persistentEnemyData.json +0 -21
  43. package/data/de/solNodes.json +0 -2242
  44. package/data/de/sortieData.json +0 -4253
  45. package/data/de/steelPath.json +0 -114
  46. package/data/de/syndicatesData.json +0 -86
  47. package/data/de/synthTargets.json +0 -1262
  48. package/data/de/tutorials.json +0 -17
  49. package/data/de/upgradeTypes.json +0 -14
  50. package/data/es/arcanes.json +0 -461
  51. package/data/es/archonShards.json +0 -224
  52. package/data/es/conclaveData.json +0 -425
  53. package/data/es/eventsData.json +0 -27
  54. package/data/es/factionsData.json +0 -32
  55. package/data/es/fissureModifiers.json +0 -26
  56. package/data/es/languages.json +0 -19595
  57. package/data/es/missionTypes.json +0 -80
  58. package/data/es/operationTypes.json +0 -6
  59. package/data/es/persistentEnemyData.json +0 -21
  60. package/data/es/solNodes.json +0 -2242
  61. package/data/es/sortieData.json +0 -4253
  62. package/data/es/steelPath.json +0 -114
  63. package/data/es/syndicatesData.json +0 -86
  64. package/data/es/synthTargets.json +0 -1262
  65. package/data/es/tutorials.json +0 -17
  66. package/data/es/upgradeTypes.json +0 -14
  67. package/data/eventsData.json +0 -27
  68. package/data/factionsData.json +0 -32
  69. package/data/fissureModifiers.json +0 -26
  70. package/data/fr/arcanes.json +0 -461
  71. package/data/fr/archonShards.json +0 -224
  72. package/data/fr/conclaveData.json +0 -425
  73. package/data/fr/eventsData.json +0 -27
  74. package/data/fr/factionsData.json +0 -32
  75. package/data/fr/fissureModifiers.json +0 -26
  76. package/data/fr/languages.json +0 -19595
  77. package/data/fr/missionTypes.json +0 -80
  78. package/data/fr/operationTypes.json +0 -6
  79. package/data/fr/persistentEnemyData.json +0 -21
  80. package/data/fr/solNodes.json +0 -2242
  81. package/data/fr/sortieData.json +0 -4253
  82. package/data/fr/steelPath.json +0 -114
  83. package/data/fr/syndicatesData.json +0 -86
  84. package/data/fr/synthTargets.json +0 -1262
  85. package/data/fr/tutorials.json +0 -17
  86. package/data/fr/upgradeTypes.json +0 -14
  87. package/data/index.html +0 -13
  88. package/data/it/arcanes.json +0 -461
  89. package/data/it/archonShards.json +0 -224
  90. package/data/it/conclaveData.json +0 -425
  91. package/data/it/eventsData.json +0 -27
  92. package/data/it/factionsData.json +0 -32
  93. package/data/it/fissureModifiers.json +0 -26
  94. package/data/it/languages.json +0 -19595
  95. package/data/it/missionTypes.json +0 -80
  96. package/data/it/operationTypes.json +0 -6
  97. package/data/it/persistentEnemyData.json +0 -21
  98. package/data/it/solNodes.json +0 -2242
  99. package/data/it/sortieData.json +0 -4253
  100. package/data/it/steelPath.json +0 -114
  101. package/data/it/syndicatesData.json +0 -86
  102. package/data/it/synthTargets.json +0 -1262
  103. package/data/it/tutorials.json +0 -17
  104. package/data/it/upgradeTypes.json +0 -14
  105. package/data/ko/arcanes.json +0 -461
  106. package/data/ko/archonShards.json +0 -224
  107. package/data/ko/conclaveData.json +0 -425
  108. package/data/ko/eventsData.json +0 -27
  109. package/data/ko/factionsData.json +0 -32
  110. package/data/ko/fissureModifiers.json +0 -26
  111. package/data/ko/languages.json +0 -19595
  112. package/data/ko/missionTypes.json +0 -80
  113. package/data/ko/operationTypes.json +0 -6
  114. package/data/ko/persistentEnemyData.json +0 -21
  115. package/data/ko/solNodes.json +0 -2242
  116. package/data/ko/sortieData.json +0 -4253
  117. package/data/ko/steelPath.json +0 -114
  118. package/data/ko/syndicatesData.json +0 -86
  119. package/data/ko/synthTargets.json +0 -1262
  120. package/data/ko/tutorials.json +0 -17
  121. package/data/ko/upgradeTypes.json +0 -14
  122. package/data/languages.json +0 -19595
  123. package/data/missionTypes.json +0 -80
  124. package/data/operationTypes.json +0 -6
  125. package/data/persistentEnemyData.json +0 -21
  126. package/data/pl/arcanes.json +0 -461
  127. package/data/pl/archonShards.json +0 -224
  128. package/data/pl/conclaveData.json +0 -425
  129. package/data/pl/eventsData.json +0 -27
  130. package/data/pl/factionsData.json +0 -32
  131. package/data/pl/fissureModifiers.json +0 -26
  132. package/data/pl/languages.json +0 -19595
  133. package/data/pl/missionTypes.json +0 -80
  134. package/data/pl/operationTypes.json +0 -6
  135. package/data/pl/persistentEnemyData.json +0 -21
  136. package/data/pl/solNodes.json +0 -2242
  137. package/data/pl/sortieData.json +0 -4253
  138. package/data/pl/steelPath.json +0 -114
  139. package/data/pl/syndicatesData.json +0 -86
  140. package/data/pl/synthTargets.json +0 -1262
  141. package/data/pl/tutorials.json +0 -17
  142. package/data/pl/upgradeTypes.json +0 -14
  143. package/data/pt/arcanes.json +0 -461
  144. package/data/pt/archonShards.json +0 -224
  145. package/data/pt/conclaveData.json +0 -425
  146. package/data/pt/eventsData.json +0 -27
  147. package/data/pt/factionsData.json +0 -32
  148. package/data/pt/fissureModifiers.json +0 -26
  149. package/data/pt/languages.json +0 -19595
  150. package/data/pt/missionTypes.json +0 -80
  151. package/data/pt/operationTypes.json +0 -6
  152. package/data/pt/persistentEnemyData.json +0 -21
  153. package/data/pt/solNodes.json +0 -2242
  154. package/data/pt/sortieData.json +0 -4253
  155. package/data/pt/steelPath.json +0 -114
  156. package/data/pt/syndicatesData.json +0 -86
  157. package/data/pt/synthTargets.json +0 -1262
  158. package/data/pt/tutorials.json +0 -17
  159. package/data/pt/upgradeTypes.json +0 -14
  160. package/data/ru/arcanes.json +0 -461
  161. package/data/ru/archonShards.json +0 -224
  162. package/data/ru/conclaveData.json +0 -425
  163. package/data/ru/eventsData.json +0 -27
  164. package/data/ru/factionsData.json +0 -32
  165. package/data/ru/fissureModifiers.json +0 -26
  166. package/data/ru/languages.json +0 -19595
  167. package/data/ru/missionTypes.json +0 -80
  168. package/data/ru/operationTypes.json +0 -6
  169. package/data/ru/persistentEnemyData.json +0 -21
  170. package/data/ru/solNodes.json +0 -2242
  171. package/data/ru/sortieData.json +0 -4253
  172. package/data/ru/steelPath.json +0 -114
  173. package/data/ru/syndicatesData.json +0 -86
  174. package/data/ru/synthTargets.json +0 -1262
  175. package/data/ru/tutorials.json +0 -17
  176. package/data/ru/upgradeTypes.json +0 -14
  177. package/data/solNodes.json +0 -2242
  178. package/data/sortieData.json +0 -4253
  179. package/data/sr/arcanes.json +0 -461
  180. package/data/sr/archonShards.json +0 -224
  181. package/data/sr/conclaveData.json +0 -425
  182. package/data/sr/eventsData.json +0 -27
  183. package/data/sr/factionsData.json +0 -32
  184. package/data/sr/fissureModifiers.json +0 -26
  185. package/data/sr/languages.json +0 -19595
  186. package/data/sr/missionTypes.json +0 -80
  187. package/data/sr/operationTypes.json +0 -6
  188. package/data/sr/persistentEnemyData.json +0 -21
  189. package/data/sr/solNodes.json +0 -2242
  190. package/data/sr/sortieData.json +0 -4253
  191. package/data/sr/steelPath.json +0 -114
  192. package/data/sr/syndicatesData.json +0 -86
  193. package/data/sr/synthTargets.json +0 -1262
  194. package/data/sr/tutorials.json +0 -17
  195. package/data/sr/upgradeTypes.json +0 -14
  196. package/data/steelPath.json +0 -33
  197. package/data/syndicatesData.json +0 -86
  198. package/data/synthTargets.json +0 -1262
  199. package/data/tr/arcanes.json +0 -461
  200. package/data/tr/archonShards.json +0 -224
  201. package/data/tr/conclaveData.json +0 -425
  202. package/data/tr/eventsData.json +0 -27
  203. package/data/tr/factionsData.json +0 -32
  204. package/data/tr/fissureModifiers.json +0 -26
  205. package/data/tr/languages.json +0 -19595
  206. package/data/tr/missionTypes.json +0 -80
  207. package/data/tr/operationTypes.json +0 -6
  208. package/data/tr/persistentEnemyData.json +0 -21
  209. package/data/tr/solNodes.json +0 -2242
  210. package/data/tr/sortieData.json +0 -4253
  211. package/data/tr/steelPath.json +0 -114
  212. package/data/tr/syndicatesData.json +0 -86
  213. package/data/tr/synthTargets.json +0 -1262
  214. package/data/tr/tutorials.json +0 -17
  215. package/data/tr/upgradeTypes.json +0 -14
  216. package/data/tutorials.json +0 -17
  217. package/data/uk/arcanes.json +0 -461
  218. package/data/uk/archonShards.json +0 -224
  219. package/data/uk/conclaveData.json +0 -425
  220. package/data/uk/eventsData.json +0 -27
  221. package/data/uk/factionsData.json +0 -32
  222. package/data/uk/fissureModifiers.json +0 -26
  223. package/data/uk/languages.json +0 -19595
  224. package/data/uk/missionTypes.json +0 -80
  225. package/data/uk/operationTypes.json +0 -6
  226. package/data/uk/persistentEnemyData.json +0 -21
  227. package/data/uk/solNodes.json +0 -2242
  228. package/data/uk/sortieData.json +0 -4253
  229. package/data/uk/steelPath.json +0 -114
  230. package/data/uk/syndicatesData.json +0 -86
  231. package/data/uk/synthTargets.json +0 -1262
  232. package/data/uk/tutorials.json +0 -17
  233. package/data/uk/upgradeTypes.json +0 -14
  234. package/data/upgradeTypes.json +0 -14
  235. package/data/zh/arcanes.json +0 -461
  236. package/data/zh/archonShards.json +0 -224
  237. package/data/zh/conclaveData.json +0 -425
  238. package/data/zh/eventsData.json +0 -27
  239. package/data/zh/factionsData.json +0 -32
  240. package/data/zh/fissureModifiers.json +0 -26
  241. package/data/zh/languages.json +0 -19595
  242. package/data/zh/missionTypes.json +0 -80
  243. package/data/zh/operationTypes.json +0 -6
  244. package/data/zh/persistentEnemyData.json +0 -21
  245. package/data/zh/solNodes.json +0 -2242
  246. package/data/zh/sortieData.json +0 -4253
  247. package/data/zh/steelPath.json +0 -114
  248. package/data/zh/syndicatesData.json +0 -86
  249. package/data/zh/synthTargets.json +0 -1262
  250. package/data/zh/tutorials.json +0 -17
  251. package/data/zh/upgradeTypes.json +0 -14
  252. package/exports.ts +0 -153
  253. package/safeImport.ts +0 -24
  254. package/tools/sortLanguages.ts +0 -44
  255. package/tools/timeDate.ts +0 -129
  256. package/tools/translation.ts +0 -430
  257. package/tools/utilities.ts +0 -4
  258. package/tsconfig.json +0 -13
  259. package/tsdown.config.ts +0 -15
  260. package/types.ts +0 -70
@@ -1,17 +0,0 @@
1
- [
2
- {
3
- "regex": "focus",
4
- "name": "专精",
5
- "url": "https://youtu.be/IMltFZ97oXc"
6
- },
7
- {
8
- "regex": "mods?",
9
- "name": "Mods",
10
- "url": "https://youtu.be/ZuYfEJzpR4A"
11
- },
12
- {
13
- "regex": "dojos?",
14
- "name": "道场",
15
- "url": "https://youtu.be/M28grdARKoQ"
16
- }
17
- ]
@@ -1,14 +0,0 @@
1
- {
2
- "GAMEPLAY_KILL_XP_AMOUNT": {
3
- "value": "任務擊殺經驗"
4
- },
5
- "GAMEPLAY_PICKUP_AMOUNT": {
6
- "value": "資源掉落加成"
7
- },
8
- "GAMEPLAY_MONEY_REWARD_AMOUNT": {
9
- "value": "現金掉落機會"
10
- },
11
- "GAMEPLAY_MONEY_PICKUP_AMOUNT": {
12
- "value": "現金掉落加成"
13
- }
14
- }
package/exports.ts DELETED
@@ -1,153 +0,0 @@
1
- import { safeImport } from './safeImport';
2
- import { Arcane, ArchonShard, Conclave, Events, SolNode, SortieData, SteelPath, SynthesisTarget } from './types';
3
-
4
- export type Locale = 'de' | 'en' | 'es' | 'fr' | 'it' | 'ko' | 'pl' | 'pt' | 'ru' | 'zh' | 'cs' | 'sr' | 'uk';
5
-
6
- const locales: Locale[] = ['de', 'es', 'fr', 'it', 'ko', 'pl', 'pt', 'ru', 'zh', 'cs', 'sr', 'uk'];
7
-
8
- /**
9
- * Bundles all the data for a particular language
10
- */
11
- export interface WorldstateLangBundle {
12
- /**
13
- * Deprecated: Array of arcane data
14
- */
15
- arcanes: Arcane[];
16
- /**
17
- * Data for Archon shard colors
18
- */
19
- archonShards: Record<string, ArchonShard>;
20
- /**
21
- * Data for translating PvP categories and types
22
- */
23
- conclave: Conclave;
24
- /**
25
- * Deprecated: Data for converting event tags to useable event data.
26
- * Deprecated in favor of keeping values in languages.json
27
- */
28
- events: Events;
29
- /**
30
- * Faction universal name to plain-usage name
31
- */
32
- factions: Record<string, { value: string }>;
33
- /**
34
- * Map of fissures to "Warframeified" tier names and numbers
35
- */
36
- fissureModifiers: Record<string, { value: string; num: number }>;
37
- /**
38
- * Map of "internal" Warframe strings to useable language strings
39
- */
40
- languages: Record<string, { value: string; desc: string }>;
41
- /**
42
- * Map of Mission Type identifiers to their corresponding values
43
- */
44
- missionTypes: Record<string, { value: string }>;
45
- /**
46
- * Global modifiers for applying operations to things like
47
- * credits, affinity, etc.
48
- */
49
- operationTypes: Record<string, { value: string; symbol: string }>;
50
- /**
51
- * Region mapping for indicies to planets
52
- */
53
- persistentEnemy: { regions: string[] };
54
- /**
55
- * Nodes in the Sol system, with enemy type and node information
56
- */
57
- solNodes: Record<string, SolNode>;
58
- /**
59
- * Sortie-specific mapping for modifier type, description, and boss
60
- */
61
- sortie: SortieData;
62
- /**
63
- * Steel Path mission type translations
64
- */
65
- steelPath: SteelPath;
66
- /**
67
- * Syndicate data
68
- */
69
- syndicates: Record<string, { name: string }>;
70
- /**
71
- * Synthesis target data for optimal locations to find targets.
72
- */
73
- synthTargets: SynthesisTarget[];
74
- /**
75
- * Official tutorials.
76
- * Not many have been released in a long time.
77
- */
78
- tutorials: { regex: string; name: string; url: string }[];
79
- /**
80
- * Global upgrade types that are modified by #operationTypes
81
- */
82
- upgradeTypes: Record<string, { value: string }>;
83
- }
84
-
85
- const makeBundle = async () => {
86
- /**
87
- * English United States translations bundle,
88
- * default translations
89
- * @type {WorldstateLangBundle}
90
- */
91
- const enUS: WorldstateLangBundle = {
92
- arcanes: await safeImport('./data/arcanes.json'),
93
- archonShards: await safeImport('./data/archonShards.json'),
94
- conclave: await safeImport('./data/conclaveData.json'),
95
- events: await safeImport('./data/eventsData.json'),
96
- factions: await safeImport('./data/factionsData.json'),
97
- fissureModifiers: await safeImport('./data/fissureModifiers.json'),
98
- languages: await safeImport('./data/languages.json'),
99
- missionTypes: await safeImport('./data/missionTypes.json'),
100
- operationTypes: await safeImport('./data/operationTypes.json'),
101
- persistentEnemy: await safeImport('./data/persistentEnemyData.json'),
102
- solNodes: await safeImport('./data/solNodes.json'),
103
- sortie: await safeImport('./data/sortieData.json'),
104
- syndicates: await safeImport('./data/syndicatesData.json'),
105
- tutorials: await safeImport('./data/tutorials.json'),
106
- upgradeTypes: await safeImport('./data/upgradeTypes.json'),
107
- synthTargets: await safeImport('./data/synthTargets.json'),
108
- steelPath: await safeImport('./data/steelPath.json'),
109
- };
110
- /* eslint-enable global-require */
111
-
112
- type WorldstateData = WorldstateLangBundle & {
113
- [K in Locale]?: WorldstateLangBundle;
114
- } & { locales: Locale[] };
115
-
116
- const bundle: WorldstateData = {
117
- en: enUS,
118
- ...enUS,
119
- locales
120
- };
121
-
122
- // eslint-disable-next-line no-restricted-syntax
123
- for await (const locale of locales) {
124
- /**
125
- * Translations bundle for $locale
126
- * @type {WorldstateLangBundle}
127
- */
128
- bundle[locale] = {
129
- arcanes: await safeImport(`./data/${locale}/arcanes.json`, enUS.arcanes),
130
- archonShards: await safeImport(`./data/${locale}/archonShards.json`, enUS.archonShards),
131
- conclave: await safeImport(`./data/${locale}/conclaveData.json`, enUS.conclave),
132
- events: await safeImport(`./data/${locale}/eventsData.json`, enUS.events),
133
- factions: await safeImport(`./data/${locale}/factionsData.json`, enUS.factions),
134
- fissureModifiers: await safeImport(`./data/${locale}/fissureModifiers.json`, enUS.fissureModifiers),
135
- languages: await safeImport(`./data/${locale}/languages.json`, enUS.languages),
136
- missionTypes: await safeImport(`./data/${locale}/missionTypes.json`, enUS.missionTypes),
137
- operationTypes: await safeImport(`./data/${locale}/operationTypes.json`, enUS.operationTypes),
138
- persistentEnemy: await safeImport(`./data/${locale}/persistentEnemyData.json`, enUS.persistentEnemy),
139
- solNodes: await safeImport(`./data/${locale}/solNodes.json`, enUS.solNodes),
140
- sortie: await safeImport(`./data/${locale}/sortieData.json`, enUS.sortie),
141
- syndicates: await safeImport(`./data/${locale}/syndicatesData.json`, enUS.syndicates),
142
- tutorials: await safeImport(`./data/${locale}/tutorials.json`, enUS.tutorials),
143
- upgradeTypes: await safeImport(`./data/${locale}/upgradeTypes.json`, enUS.upgradeTypes),
144
- synthTargets: await safeImport(`./data/${locale}/synthTargets.json`, enUS.synthTargets),
145
- steelPath: await safeImport(`./data/${locale}/steelPath.json`, enUS.steelPath),
146
- };
147
- }
148
-
149
- locales.push('en');
150
- return bundle;
151
- };
152
-
153
- export default await makeBundle();
package/safeImport.ts DELETED
@@ -1,24 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
2
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
3
-
4
- /**
5
- * Safely require path, fall back to fallback if module cannot load
6
- * @param {string} path Path to attempt to load
7
- * @param {Object} fallback fallback response if error or no module
8
- * @returns {Promise<any>} module or the default object
9
- */
10
- export const safeImport = async <T extends object>(path: string, fallback: T = {} as T): Promise<T> => {
11
- try {
12
- const mod: T | { default: T } = path.includes('.json')
13
- ? await import(path, { with: { type: 'json' } })
14
- : await import(path);
15
- return 'default' in mod ? (mod as { default: T }).default : (mod as T);
16
- } catch (error) {
17
- if ((process.env.LOG_LEVEL || 'ERROR').toUpperCase() === 'DEBUG') {
18
- console.debug(`Failed to load module at ${path} ... returning fallback`);
19
- }
20
-
21
- return fallback;
22
- }
23
- };
24
-
@@ -1,44 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { readFile, writeFile } from 'node:fs/promises';
4
- import { dirname, join } from 'node:path';
5
- import { fileURLToPath } from 'node:url';
6
-
7
- import yargs from 'yargs/yargs';
8
-
9
- const options = yargs(process.argv)
10
- .usage('Usage -c')
11
- .option('c', { alias: 'check', describe: "Check only, don't write file", type: 'boolean', demandOption: false })
12
- .parse();
13
-
14
- const checkOnly = (await options).c;
15
-
16
- const dirName: string = dirname(fileURLToPath(import.meta.url));
17
- const sort = (obj: Record<string, { value: string; desc?: string }>) => {
18
- return Object.keys(obj)
19
- .sort()
20
- .reduce(
21
- function (result, key: string) {
22
- result[key] = obj[key];
23
- return result;
24
- },
25
- {} as Record<string, { value: string; desc?: string }>
26
- );
27
- };
28
-
29
- const dataDir = join(dirName, '..', 'data');
30
- const data = JSON.parse(await readFile(join(dataDir, 'languages.json'), 'utf8'));
31
-
32
- const sortedData = sort(data);
33
-
34
- if (JSON.stringify(sortedData, undefined, 2) !== JSON.stringify(data, undefined, 2)) {
35
- console.error('Data not sorted');
36
- if (checkOnly) { process.exit(1); }
37
- }
38
-
39
- if (checkOnly) { process.exit(0); }
40
-
41
- await writeFile(join(dataDir, 'languages.json.bak'), JSON.stringify(data, undefined, 2));
42
- await writeFile(join(dataDir, 'languages.json'), JSON.stringify(sortedData, undefined, 2));
43
-
44
- console.log('language.json has been sorted!');
package/tools/timeDate.ts DELETED
@@ -1,129 +0,0 @@
1
- const epochZero: ContentTimestamp = {
2
- $date: {
3
- $numberLong: 0,
4
- },
5
- };
6
-
7
- export const pieceIsSmoller = (seconds: number, ceiling: number, label: string, timePieces: string[]) => {
8
- if (seconds >= ceiling) {
9
- timePieces.push(`${Math.floor(seconds / ceiling)}${label}`);
10
- seconds = Math.floor(seconds) % ceiling;
11
- }
12
- return { seconds, timePieces };
13
- };
14
-
15
- /**
16
- * @param {number} millis The number of milliseconds in the time delta
17
- * @returns {string} formatted time delta
18
- */
19
- export const timeDeltaToString = (millis: number): string => {
20
- if (typeof millis !== 'number') {
21
- throw new TypeError('millis should be a number');
22
- }
23
-
24
- let timePieces: string[] = [];
25
- const prefix = millis < 0 ? '-' : '';
26
- let seconds = Math.abs(millis / 1000);
27
-
28
- // Seconds in a day
29
- ({ seconds, timePieces } = pieceIsSmoller(seconds, 86400, 'd', timePieces));
30
-
31
- // Seconds in an hour
32
- ({ seconds, timePieces } = pieceIsSmoller(seconds, 3600, 'h', timePieces));
33
-
34
- // Seconds in a minute
35
- ({ seconds, timePieces } = pieceIsSmoller(seconds, 60, 'm', timePieces));
36
-
37
- /* istanbul ignore else */
38
- if (seconds >= 0) {
39
- timePieces.push(`${Math.floor(seconds)}s`);
40
- }
41
- return `${prefix}${timePieces.join(' ')}`;
42
- };
43
-
44
- /**
45
- * Returns the number of milliseconds between now and a given date
46
- * @param {Date} d The date from which the current time will be subtracted
47
- * @param {function} [now] A function that returns the current UNIX time in milliseconds
48
- * @returns {number} The number of milliseconds after the given date to now
49
- */
50
- export const fromNow = (d: Date, now: () => number = Date.now): number => {
51
- return d.getTime() - now();
52
- };
53
-
54
- /**
55
- * Returns the number of milliseconds between a given date and now
56
- * @param {Date} d The date that the current time will be subtracted from
57
- * @param {function} [now] A function that returns the current UNIX time in milliseconds
58
- * @returns {number} The number of milliseconds after now to the given date
59
- */
60
- export const toNow = (d: Date, now: () => number = Date.now): number => {
61
- return now() - d.getTime();
62
- };
63
-
64
- export interface ContentTimestamp {
65
- $date?: { $numberLong: number };
66
- }
67
-
68
- /**
69
- * Returns a new Date constructed from a worldState date object
70
- * @param {Object} d The worldState date object
71
- * @returns {Date} parsed date from DE date format
72
- */
73
- export const parseDate = (d?: ContentTimestamp): Date => {
74
- const safeD = d || epochZero;
75
- const dt = safeD.$date || epochZero.$date;
76
- return new Date(safeD.$date ? Number(dt!.$numberLong) : 1000 * (d as { sec: number }).sec);
77
- };
78
-
79
- /**
80
- * Get a weekly reset timestamp
81
- */
82
- export const weeklyReset = (nowFunc = () => new Date()): { activation: Date; expiry: Date } => {
83
- const now = nowFunc();
84
- const currentDay = now.getUTCDay();
85
- const daysUntilNextMonday = currentDay === 0 ? 1 : 8 - currentDay;
86
-
87
- const expiry = new Date(now.getTime());
88
- expiry.setUTCDate(now.getUTCDate() + daysUntilNextMonday);
89
- expiry.setUTCHours(0, 0, 0, 0);
90
-
91
- const activation = new Date(expiry.getTime());
92
- activation.setUTCDate(expiry.getUTCDate() - 7);
93
-
94
- return { activation, expiry };
95
- };
96
-
97
- /**
98
- * Get a daily reset timestamp
99
- */
100
- export const dailyReset = (nowFunc = () => new Date()): { activation: Date; expiry: Date } => {
101
- const now = nowFunc();
102
-
103
- const activation = new Date(now.getTime());
104
- activation.setUTCHours(0, 0, 0, 0);
105
-
106
- const expiry = new Date(now.getTime());
107
- expiry.setUTCDate(now.getUTCDate() + 1);
108
- expiry.setUTCHours(0, 0, 0, 0);
109
-
110
- return {activation, expiry};
111
- };
112
-
113
- /**
114
- * An object containing functions to format dates and times
115
- * @typedef {Record<string, Function>} TimeDateFunctions
116
- * @property {Function} timeDeltaToString - Converts a time difference to a string
117
- * @property {Function} fromNow - Returns the number of milliseconds between now and
118
- * a given date
119
- * @property {Function} toNow - Returns the number of milliseconds between a given
120
- * date and now
121
- */
122
- export default {
123
- timeDeltaToString,
124
- fromNow,
125
- toNow,
126
- parseDate,
127
- dailyReset,
128
- weeklyReset,
129
- };