warframe-worldstate-parser 3.0.1 → 3.0.3

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 (52) hide show
  1. package/lib/WorldState.js +1 -1
  2. package/lib/models/Alert.js +2 -1
  3. package/lib/models/CambionCycle.js +1 -1
  4. package/lib/models/CetusCycle.js +2 -1
  5. package/lib/models/ChallengeInstance.js +1 -1
  6. package/lib/models/ConclaveChallenge.js +8 -2
  7. package/lib/models/DailyDeal.js +2 -2
  8. package/lib/models/DarkSector.js +1 -2
  9. package/lib/models/DarkSectorBattle.js +1 -1
  10. package/lib/models/DuviriCycle.js +1 -2
  11. package/lib/models/EarthCycle.js +2 -1
  12. package/lib/models/Fissure.js +4 -2
  13. package/lib/models/FlashSale.js +2 -2
  14. package/lib/models/GlobalUpgrade.js +9 -2
  15. package/lib/models/Invasion.js +2 -2
  16. package/lib/models/Kuva.js +1 -1
  17. package/lib/models/Mission.js +2 -2
  18. package/lib/models/News.js +2 -2
  19. package/lib/models/Nightwave.js +2 -2
  20. package/lib/models/NightwaveChallenge.js +1 -1
  21. package/lib/models/PersistentEnemy.js +2 -2
  22. package/lib/models/Reward.js +2 -2
  23. package/lib/models/SentientOutpost.js +3 -4
  24. package/lib/models/Simaris.js +1 -1
  25. package/lib/models/Sortie.js +8 -2
  26. package/lib/models/SortieVariant.js +2 -2
  27. package/lib/models/SteelPathOffering.js +1 -2
  28. package/lib/models/SyndicateJob.js +1 -1
  29. package/lib/models/SyndicateMission.js +2 -2
  30. package/lib/models/VallisCycle.js +2 -1
  31. package/lib/models/VoidTrader.js +2 -3
  32. package/lib/models/VoidTraderItem.js +1 -1
  33. package/lib/models/VoidTraderSchedule.js +1 -2
  34. package/lib/models/WorldEvent.js +2 -2
  35. package/lib/models/WorldstateObject.js +1 -2
  36. package/lib/models/ZarimanCycle.js +2 -1
  37. package/package.json +8 -3
  38. package/types/lib/models/CetusCycle.d.ts +2 -2
  39. package/types/lib/models/SentientOutpost.d.ts +3 -3
  40. package/types/lib/models/SortieVariant.d.ts +2 -2
  41. package/types/lib/models/SteelPathOffering.d.ts +1 -1
  42. package/types/lib/models/VoidTrader.d.ts +1 -1
  43. package/types/lib/models/VoidTraderItem.d.ts +1 -1
  44. package/types/lib/models/VoidTraderSchedule.d.ts +2 -2
  45. package/types/lib/models/WorldEvent.d.ts +5 -5
  46. package/types/lib/models/ZarimanCycle.d.ts +2 -2
  47. package/lib/utilities/integrity.js +0 -11
  48. package/lib/utilities/timeDate.js +0 -86
  49. package/lib/utilities/translation.js +0 -386
  50. package/types/lib/utilities/integrity.d.ts +0 -1
  51. package/types/lib/utilities/timeDate.d.ts +0 -36
  52. package/types/lib/utilities/translation.d.ts +0 -192
package/lib/WorldState.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import wsData from 'warframe-worldstate-data';
2
+ import { parseDate } from 'warframe-worldstate-data/utilities';
2
3
 
3
4
  import EarthCycle from './models/EarthCycle.js';
4
5
  import CetusCycle from './models/CetusCycle.js';
@@ -12,7 +13,6 @@ import CambionCycle from './models/CambionCycle.js';
12
13
  import SteelPathOffering from './models/SteelPathOffering.js';
13
14
  import Dependency from './supporting/Dependency.js'; // eslint-disable-line no-unused-vars
14
15
  import DuviriCycle from './models/DuviriCycle.js';
15
- import { parseDate } from './utilities/timeDate.js';
16
16
  import WeeklyChallenge from './models/WeeklyChallenge.js';
17
17
  import Sortie from './models/Sortie.js';
18
18
  import DuviriChoice from './supporting/DuviriChoice.js';
@@ -1,5 +1,6 @@
1
+ import { fromNow, timeDeltaToString } from 'warframe-worldstate-data/utilities';
2
+
1
3
  import mdConfig from '../supporting/MarkdownSettings.js';
2
- import { fromNow, timeDeltaToString } from '../utilities/timeDate.js';
3
4
 
4
5
  import WorldstateObject from './WorldstateObject.js';
5
6
  import Mission from './Mission.js';
@@ -1,4 +1,4 @@
1
- import { fromNow } from '../utilities/timeDate.js';
1
+ import { fromNow } from 'warframe-worldstate-data/utilities';
2
2
 
3
3
  import WorldstateObject from './WorldstateObject.js';
4
4
 
@@ -1,5 +1,6 @@
1
+ import { fromNow, timeDeltaToString } from 'warframe-worldstate-data/utilities';
2
+
1
3
  import mdConfig from '../supporting/MarkdownSettings.js';
2
- import { fromNow, timeDeltaToString } from '../utilities/timeDate.js';
3
4
 
4
5
  import WorldstateObject from './WorldstateObject.js';
5
6
 
@@ -1,4 +1,4 @@
1
- import { languageString } from '../utilities/translation.js';
1
+ import { languageString } from 'warframe-worldstate-data/utilities';
2
2
 
3
3
  /**
4
4
  * Describes a world challenge instance
@@ -1,5 +1,11 @@
1
- import { parseDate, fromNow, timeDeltaToString } from '../utilities/timeDate.js';
2
- import { conclaveMode, conclaveCategory, conclaveChallenge } from '../utilities/translation.js';
1
+ import {
2
+ parseDate,
3
+ fromNow,
4
+ timeDeltaToString,
5
+ conclaveMode,
6
+ conclaveCategory,
7
+ conclaveChallenge,
8
+ } from 'warframe-worldstate-data/utilities';
3
9
 
4
10
  import WorldstateObject from './WorldstateObject.js';
5
11
 
@@ -1,6 +1,6 @@
1
+ import { parseDate, timeDeltaToString, fromNow, languageString } from 'warframe-worldstate-data/utilities';
2
+
1
3
  import mdConfig from '../supporting/MarkdownSettings.js';
2
- import { languageString } from '../utilities/translation.js';
3
- import { parseDate, timeDeltaToString, fromNow } from '../utilities/timeDate.js';
4
4
 
5
5
  /**
6
6
  * Represents a daily deal
@@ -1,5 +1,4 @@
1
- import { parseDate } from '../utilities/timeDate.js';
2
- import { languageString } from '../utilities/translation.js';
1
+ import { parseDate, languageString } from 'warframe-worldstate-data/utilities';
3
2
 
4
3
  import WorldstateObject from './WorldstateObject.js';
5
4
  import Mission from './Mission.js';
@@ -1,4 +1,4 @@
1
- import { parseDate } from '../utilities/timeDate.js';
1
+ import { parseDate } from 'warframe-worldstate-data/utilities';
2
2
 
3
3
  /**
4
4
  * Represents a battle over a dark sector
@@ -1,5 +1,4 @@
1
- import { toTitleCase } from '../utilities/translation.js';
2
- import { timeDeltaToString } from '../utilities/timeDate.js';
1
+ import { timeDeltaToString, toTitleCase } from 'warframe-worldstate-data/utilities';
3
2
 
4
3
  import WorldstateObject from './WorldstateObject.js';
5
4
 
@@ -1,4 +1,5 @@
1
- import { fromNow } from '../utilities/timeDate.js';
1
+ import { fromNow } from 'warframe-worldstate-data/utilities';
2
+
2
3
  import mdConfig from '../supporting/MarkdownSettings.js';
3
4
 
4
5
  import WorldstateObject from './WorldstateObject.js';
@@ -1,12 +1,14 @@
1
1
  import {
2
+ parseDate,
3
+ fromNow,
4
+ timeDeltaToString,
2
5
  node,
3
6
  nodeMissionType,
4
7
  missionType,
5
8
  nodeEnemy,
6
9
  fissureModifier,
7
10
  fissureTier,
8
- } from '../utilities/translation.js';
9
- import { parseDate, fromNow, timeDeltaToString } from '../utilities/timeDate.js';
11
+ } from 'warframe-worldstate-data/utilities';
10
12
 
11
13
  import WorldstateObject from './WorldstateObject.js';
12
14
 
@@ -1,6 +1,6 @@
1
+ import { parseDate, fromNow, timeDeltaToString, languageString } from 'warframe-worldstate-data/utilities';
2
+
1
3
  import mdConfig from '../supporting/MarkdownSettings.js';
2
- import { languageString } from '../utilities/translation.js';
3
- import { parseDate, fromNow, timeDeltaToString } from '../utilities/timeDate.js';
4
4
 
5
5
  /**
6
6
  * Represents a flash sale
@@ -1,6 +1,13 @@
1
+ import {
2
+ parseDate,
3
+ fromNow,
4
+ timeDeltaToString,
5
+ upgrade,
6
+ operation,
7
+ operationSymbol,
8
+ } from 'warframe-worldstate-data/utilities';
9
+
1
10
  import mdConfig from '../supporting/MarkdownSettings.js';
2
- import { parseDate, fromNow, timeDeltaToString } from '../utilities/timeDate.js';
3
- import { upgrade, operation, operationSymbol } from '../utilities/translation.js';
4
11
  /**
5
12
  * Represents an upgrade that applies to all players
6
13
  */
@@ -1,5 +1,5 @@
1
- import { node, languageString, faction } from '../utilities/translation.js';
2
- import { parseDate, timeDeltaToString, toNow } from '../utilities/timeDate.js';
1
+ import { parseDate, timeDeltaToString, toNow, node, languageString, faction } from 'warframe-worldstate-data/utilities';
2
+
3
3
  import mdConfig from '../supporting/MarkdownSettings.js';
4
4
 
5
5
  import Reward from './Reward.js';
@@ -1,6 +1,6 @@
1
1
  import { createHash } from 'node:crypto';
2
2
 
3
- import { node, nodeMissionType } from '../utilities/translation.js';
3
+ import { node, nodeMissionType } from 'warframe-worldstate-data/utilities';
4
4
 
5
5
  /**
6
6
  * External mission data retrieved from https://10o.io/kuvalog.json
@@ -1,6 +1,6 @@
1
+ import { languageString, faction, missionType, node, insist } from 'warframe-worldstate-data/utilities';
2
+
1
3
  import mdConfig from '../supporting/MarkdownSettings.js';
2
- import { languageString, faction, missionType, node } from '../utilities/translation.js';
3
- import { insist } from '../utilities/integrity.js';
4
4
 
5
5
  import Reward from './Reward.js';
6
6
 
@@ -1,6 +1,6 @@
1
+ import { fromNow, parseDate, timeDeltaToString, toNow, languageString } from 'warframe-worldstate-data/utilities';
2
+
1
3
  import mdConfig from '../supporting/MarkdownSettings.js';
2
- import { languageString } from '../utilities/translation.js';
3
- import { fromNow, parseDate, timeDeltaToString, toNow } from '../utilities/timeDate.js';
4
4
 
5
5
  import WorldstateObject from './WorldstateObject.js';
6
6
 
@@ -1,5 +1,5 @@
1
- import { languageString } from '../utilities/translation.js';
2
- import { fromNow, timeDeltaToString } from '../utilities/timeDate.js';
1
+ import { fromNow, timeDeltaToString, languageString } from 'warframe-worldstate-data/utilities';
2
+
3
3
  import mdConfig from '../supporting/MarkdownSettings.js';
4
4
 
5
5
  import WorldstateObject from './WorldstateObject.js';
@@ -1,4 +1,4 @@
1
- import { languageDesc, languageString } from '../utilities/translation.js';
1
+ import { languageDesc, languageString } from 'warframe-worldstate-data/utilities';
2
2
 
3
3
  import WorldstateObject from './WorldstateObject.js';
4
4
 
@@ -1,5 +1,5 @@
1
- import { languageString, node, region } from '../utilities/translation.js';
2
- import { parseDate } from '../utilities/timeDate.js';
1
+ import { parseDate, languageString, node, region } from 'warframe-worldstate-data/utilities';
2
+
3
3
  import mdConfig from '../supporting/MarkdownSettings.js';
4
4
 
5
5
  import WorldstateObject from './WorldstateObject.js';
@@ -1,6 +1,6 @@
1
+ import { languageString, insist } from 'warframe-worldstate-data/utilities';
2
+
1
3
  import rewardTypes from '../supporting/RewardTypes.js';
2
- import { languageString } from '../utilities/translation.js';
3
- import { insist } from '../utilities/integrity.js';
4
4
 
5
5
  /**
6
6
  * An object describing a type of reward, including name, description,
@@ -1,4 +1,4 @@
1
- import { node, nodeEnemy, nodeMissionType } from '../utilities/translation.js';
1
+ import { node, nodeEnemy, nodeMissionType } from 'warframe-worldstate-data/utilities';
2
2
 
3
3
  const duration = 1800;
4
4
 
@@ -42,12 +42,11 @@ const sat = () => {
42
42
  export default class SentientOutpost {
43
43
  #node;
44
44
  constructor(data, { locale, sentientData, logger }) {
45
- // eslint-disable-next-line no-param-reassign
46
45
  if (!data) data = '{"sfn":000}';
47
46
  [this.#node] = data.match(/\d{3}/g) || ['000'];
48
- const id = `CrewBattleNode${node}`;
47
+ const id = `CrewBattleNode${this.#node}`;
49
48
  /* istanbul ignore if */
50
- if (node === '000') {
49
+ if (this.#node === '000') {
51
50
  this.mission = undefined;
52
51
  } else {
53
52
  this.mission = {
@@ -1,4 +1,4 @@
1
- import { languageString } from '../utilities/translation.js';
1
+ import { languageString } from 'warframe-worldstate-data/utilities';
2
2
 
3
3
  /**
4
4
  * Contains information about sanctuary targets
@@ -1,8 +1,14 @@
1
1
  import wsData from 'warframe-worldstate-data';
2
+ import {
3
+ fromNow,
4
+ parseDate,
5
+ timeDeltaToString,
6
+ languageString,
7
+ sortieBoss,
8
+ sortieFaction,
9
+ } from 'warframe-worldstate-data/utilities';
2
10
 
3
11
  import mdConfig from '../supporting/MarkdownSettings.js';
4
- import { fromNow, parseDate, timeDeltaToString } from '../utilities/timeDate.js';
5
- import { languageString, sortieBoss, sortieFaction } from '../utilities/translation.js';
6
12
 
7
13
  import WorldstateObject from './WorldstateObject.js';
8
14
  import SortieVariant from './SortieVariant.js';
@@ -1,6 +1,6 @@
1
- import { missionType, node, sortieModDesc, sortieModifier } from '../utilities/translation.js';
1
+ import { missionType, node, sortieModDesc, sortieModifier, insist } from 'warframe-worldstate-data/utilities';
2
+
2
3
  import mdConfig from '../supporting/MarkdownSettings.js';
3
- import { insist } from '../utilities/integrity.js';
4
4
 
5
5
  /**
6
6
  * Represents a sortie variant
@@ -1,5 +1,4 @@
1
- import { steelPath } from '../utilities/translation.js';
2
- import { timeDeltaToString } from '../utilities/timeDate.js';
1
+ import { timeDeltaToString, steelPath } from 'warframe-worldstate-data/utilities';
3
2
 
4
3
  const monday = 1;
5
4
 
@@ -1,4 +1,4 @@
1
- import { languageString } from '../utilities/translation.js';
1
+ import { languageString } from 'warframe-worldstate-data/utilities';
2
2
 
3
3
  import WorldstateObject from './WorldstateObject.js';
4
4
 
@@ -1,5 +1,5 @@
1
- import { node, syndicate } from '../utilities/translation.js';
2
- import { fromNow, parseDate, timeDeltaToString } from '../utilities/timeDate.js';
1
+ import { fromNow, parseDate, timeDeltaToString, node, syndicate } from 'warframe-worldstate-data/utilities';
2
+
3
3
  import mdConfig from '../supporting/MarkdownSettings.js';
4
4
 
5
5
  import SyndicateJob from './SyndicateJob.js';
@@ -1,4 +1,5 @@
1
- import { fromNow, timeDeltaToString } from '../utilities/timeDate.js';
1
+ import { fromNow, timeDeltaToString } from 'warframe-worldstate-data/utilities';
2
+
2
3
  import mdConfig from '../supporting/MarkdownSettings.js';
3
4
 
4
5
  import WorldstateObject from './WorldstateObject.js';
@@ -1,6 +1,5 @@
1
- import { fromNow, parseDate, timeDeltaToString } from '../utilities/timeDate.js';
2
- import { node } from '../utilities/translation.js';
3
- import { insist } from '../utilities/integrity.js';
1
+ import { fromNow, parseDate, timeDeltaToString, node, insist } from 'warframe-worldstate-data/utilities';
2
+
4
3
  import mdConfig from '../supporting/MarkdownSettings.js';
5
4
 
6
5
  import WorldstateObject from './WorldstateObject.js';
@@ -1,4 +1,4 @@
1
- import { languageString } from '../utilities/translation.js';
1
+ import { languageString } from 'warframe-worldstate-data/utilities';
2
2
 
3
3
  /**
4
4
  * A void trader inventory item
@@ -1,5 +1,4 @@
1
- import { parseDate } from '../utilities/timeDate.js';
2
- import { languageString } from '../utilities/translation.js';
1
+ import { parseDate, languageString } from 'warframe-worldstate-data/utilities';
3
2
 
4
3
  export default class VoidTraderSchedule {
5
4
  constructor(data, { locale = 'en' } = { locale: 'en' }) {
@@ -1,5 +1,5 @@
1
- import { fromNow, parseDate } from '../utilities/timeDate.js';
2
- import { faction, languageString, node, syndicate } from '../utilities/translation.js';
1
+ import { fromNow, parseDate, faction, languageString, node, syndicate } from 'warframe-worldstate-data/utilities';
2
+
3
3
  import mdConfig from '../supporting/MarkdownSettings.js';
4
4
 
5
5
  import WorldstateObject from './WorldstateObject.js';
@@ -1,5 +1,4 @@
1
- import { parseDate, fromNow, timeDeltaToString } from '../utilities/timeDate.js';
2
- import { insist } from '../utilities/integrity.js';
1
+ import { parseDate, fromNow, timeDeltaToString, insist } from 'warframe-worldstate-data/utilities';
3
2
 
4
3
  /**
5
4
  * @typedef {object} Identifier
@@ -1,4 +1,5 @@
1
- import { fromNow, timeDeltaToString } from '../utilities/timeDate.js';
1
+ import { fromNow, timeDeltaToString } from 'warframe-worldstate-data/utilities';
2
+
2
3
  import mdConfig from '../supporting/MarkdownSettings.js';
3
4
 
4
5
  import WorldstateObject from './WorldstateObject.js';
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "warframe-worldstate-parser",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "An Open parser for Warframe's Worldstate in Javascript",
5
5
  "types": "./types/main.d.ts",
6
6
  "main": "main.js",
7
7
  "peerDependencies": {
8
- "warframe-worldstate-data": ">=1.0"
8
+ "warframe-worldstate-data": ">=2.0.3"
9
9
  },
10
10
  "engines": {
11
11
  "node": ">=18.19.0"
@@ -30,5 +30,10 @@
30
30
  "url": "https://github.com/wfcd/warframe-worldstate-parser/issues"
31
31
  },
32
32
  "homepage": "https://github.com/wfcd/warframe-worldstate-parser#readme",
33
- "type": "module"
33
+ "type": "module",
34
+ "overrides": {
35
+ "sinon-chai": {
36
+ "chai": "^5.0.3"
37
+ }
38
+ }
34
39
  }
@@ -36,9 +36,9 @@ export default class CetusCycle extends WorldstateObject {
36
36
  getExpired(): boolean;
37
37
  getCurrentCetusCycle(): {
38
38
  dayTime: boolean;
39
- timeLeft: string;
39
+ timeLeft: any;
40
40
  expiry: Date;
41
- expiresIn: number;
41
+ expiresIn: any;
42
42
  state: string;
43
43
  start: number;
44
44
  };
@@ -25,9 +25,9 @@ export default class SentientOutpost {
25
25
  logger: any;
26
26
  });
27
27
  mission: {
28
- node: string;
29
- faction: string;
30
- type: string;
28
+ node: any;
29
+ faction: any;
30
+ type: any;
31
31
  };
32
32
  active: boolean;
33
33
  id: string;
@@ -18,7 +18,7 @@ export default class SortieVariant {
18
18
  * @type {string}
19
19
  */
20
20
  missionType: string;
21
- missionTypeKey: string;
21
+ missionTypeKey: any;
22
22
  /**
23
23
  * The variant's modifier
24
24
  * @type {string}
@@ -34,7 +34,7 @@ export default class SortieVariant {
34
34
  * @type {string}
35
35
  */
36
36
  node: string;
37
- nodeKey: string;
37
+ nodeKey: any;
38
38
  /**
39
39
  * Returns a string representation of the sortie variant
40
40
  * @returns {string} string representation
@@ -5,7 +5,7 @@ export default class SteelPathOffering {
5
5
  currentReward: any;
6
6
  activation: Date;
7
7
  expiry: Date;
8
- remaining: string;
8
+ remaining: any;
9
9
  rotation: any;
10
10
  evergreens: any;
11
11
  /**
@@ -37,7 +37,7 @@ export default class VoidTrader extends WorldstateObject {
37
37
  * @type {string}
38
38
  */
39
39
  endString: string;
40
- initialStart: Date;
40
+ initialStart: any;
41
41
  completed: any;
42
42
  schedule: any;
43
43
  }
@@ -19,7 +19,7 @@ export default class VoidTraderItem {
19
19
  RegularPrice: string;
20
20
  }, { locale }?: Dependency);
21
21
  uniqueName: string;
22
- item: string;
22
+ item: any;
23
23
  ducats: number;
24
24
  credits: number;
25
25
  }
@@ -2,6 +2,6 @@ export default class VoidTraderSchedule {
2
2
  constructor(data: any, { locale }?: {
3
3
  locale?: string;
4
4
  });
5
- expiry: Date;
6
- item: string;
5
+ expiry: any;
6
+ item: any;
7
7
  }
@@ -95,7 +95,7 @@ export default class WorldEvent extends WorldstateObject {
95
95
  * @type {number}
96
96
  */
97
97
  health: number;
98
- affiliatedWith: string;
98
+ affiliatedWith: any;
99
99
  jobs: any;
100
100
  previousJobs: any;
101
101
  /**
@@ -155,11 +155,11 @@ export default class WorldEvent extends WorldstateObject {
155
155
  */
156
156
  completionBonuses: Array<number>;
157
157
  scoreVar: any;
158
- altExpiry: Date;
159
- altActivation: Date;
158
+ altExpiry: any;
159
+ altActivation: any;
160
160
  nextAlt: {
161
- expiry: Date;
162
- activation: Date;
161
+ expiry: any;
162
+ activation: any;
163
163
  };
164
164
  /**
165
165
  * Get whether or not the event has expired
@@ -31,9 +31,9 @@ export default class ZarimanCycle extends WorldstateObject {
31
31
  getExpired(): boolean;
32
32
  getCurrentZarimanCycle(): {
33
33
  isCorpus: boolean;
34
- timeLeft: string;
34
+ timeLeft: any;
35
35
  expiry: Date;
36
- expiresIn: number;
36
+ expiresIn: any;
37
37
  state: string;
38
38
  start: number;
39
39
  };
@@ -1,11 +0,0 @@
1
- // eslint-disable-next-line import/prefer-default-export
2
- export const insist = (thing, ...args) => {
3
- if (!thing || !Object.keys(thing).length) {
4
- throw new TypeError(`The provided data does not have the required properties.`);
5
- }
6
- args.forEach((arg) => {
7
- if (!thing[arg]) {
8
- throw new TypeError(`The provided data does not have the required properties.`);
9
- }
10
- });
11
- };
@@ -1,86 +0,0 @@
1
- const epochZero = {
2
- $date: {
3
- $numberLong: 0,
4
- },
5
- };
6
-
7
- /**
8
- * @param {number} millis The number of milliseconds in the time delta
9
- * @returns {string} formatted time delta
10
- */
11
- export function timeDeltaToString(millis) {
12
- if (typeof millis !== 'number') {
13
- throw new TypeError('millis should be a number');
14
- }
15
- const timePieces = [];
16
- const prefix = millis < 0 ? '-' : '';
17
- let seconds = Math.abs(millis / 1000);
18
-
19
- // Seconds in a day
20
- if (seconds >= 86400) {
21
- timePieces.push(`${Math.floor(seconds / 86400)}d`);
22
- seconds = Math.floor(seconds) % 86400;
23
- }
24
- // Seconds in an hour
25
- if (seconds >= 3600) {
26
- timePieces.push(`${Math.floor(seconds / 3600)}h`);
27
- seconds = Math.floor(seconds) % 3600;
28
- }
29
- if (seconds >= 60) {
30
- timePieces.push(`${Math.floor(seconds / 60)}m`);
31
- seconds = Math.floor(seconds) % 60;
32
- }
33
-
34
- /* istanbul ignore else */
35
- if (seconds >= 0) {
36
- timePieces.push(`${Math.floor(seconds)}s`);
37
- }
38
- return `${prefix}${timePieces.join(' ')}`;
39
- }
40
-
41
- /**
42
- * Returns the number of milliseconds between now and a given date
43
- * @param {Date} d The date from which the current time will be subtracted
44
- * @param {Function} [now] A function that returns the current UNIX time in milliseconds
45
- * @returns {number} The number of milliseconds after the given date to now
46
- */
47
- export function fromNow(d, now = Date.now) {
48
- return d.getTime() - now();
49
- }
50
-
51
- /**
52
- * Returns the number of milliseconds between a given date and now
53
- * @param {Date} d The date that the current time will be subtracted from
54
- * @param {Function} [now] A function that returns the current UNIX time in milliseconds
55
- * @returns {number} The number of milliseconds after now to the given date
56
- */
57
- export function toNow(d, now = Date.now) {
58
- return now() - d.getTime();
59
- }
60
-
61
- /**
62
- * Returns a new Date constructed from a worldState date object
63
- * @param {object} d The worldState date object
64
- * @returns {Date} parsed date from DE date format
65
- */
66
- export function parseDate(d) {
67
- const safeD = d || epochZero;
68
- const dt = safeD.$date || epochZero.$date;
69
- return new Date(safeD.$date ? Number(dt.$numberLong) : 1000 * d.sec);
70
- }
71
-
72
- /**
73
- * An object containing functions to format dates and times
74
- * @typedef {Record<string, Function>} TimeDateFunctions
75
- * @property {Function} timeDeltaToString - Converts a time difference to a string
76
- * @property {Function} fromNow - Returns the number of milliseconds between now and
77
- * a given date
78
- * @property {Function} toNow - Returns the number of milliseconds between a given
79
- * date and now
80
- */
81
- export default {
82
- timeDeltaToString,
83
- fromNow,
84
- toNow,
85
- parseDate,
86
- };
@@ -1,386 +0,0 @@
1
- import data from 'warframe-worldstate-data';
2
-
3
- /**
4
- * Rough Titlecase!
5
- * @param {string} str string to be titlecased
6
- * @returns {string} titlecased string
7
- */
8
- export function toTitleCase(str) {
9
- return str.replace(/\w\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
10
- }
11
-
12
- /**
13
- * Utility function to split the resource name and return somewhat human-readable string
14
- * @param {string} str localization resource key
15
- * @returns {string} human-readable string
16
- */
17
- export function splitResourceName(str) {
18
- return str
19
- .split(/([A-Z]?[^A-Z]*)/g)
20
- .filter(Boolean)
21
- .join(' ');
22
- }
23
-
24
- const i18n = (locale = 'en') => data[locale] || data;
25
-
26
- /**
27
- *
28
- * @param {string} key - The data key
29
- * @param {string} dataOverride locale for use with translation
30
- * @returns {string} faction name
31
- */
32
- export function faction(key, dataOverride) {
33
- if (key in i18n(dataOverride).factions) {
34
- return i18n(dataOverride).factions[key].value;
35
- }
36
- return key;
37
- }
38
-
39
- /**
40
- *
41
- * @param {string} key - The data key
42
- * @param {string} dataOverride locale for use with translation
43
- * @returns {string} node name
44
- */
45
- export function node(key, dataOverride) {
46
- if (key in i18n(dataOverride).solNodes) {
47
- return i18n(dataOverride).solNodes[key].value;
48
- }
49
- if (key) {
50
- return key.split('/').slice(-1)[0];
51
- }
52
- return key;
53
- }
54
-
55
- /**
56
- *
57
- * @param {string} key - The data key
58
- * @param {string} dataOverride locale for use with translation
59
- * @returns {string} mission type of the node
60
- */
61
- export function nodeMissionType(key, dataOverride) {
62
- if (key in i18n(dataOverride).solNodes) {
63
- return i18n(dataOverride).solNodes[key].type;
64
- }
65
- if (key) {
66
- return key.split('/').slice(-1)[0];
67
- }
68
- return key;
69
- }
70
-
71
- /**
72
- *
73
- * @param {string} key - The data key
74
- * @param {string} dataOverride locale for use with translation
75
- * @returns {string} faction that controls the node
76
- */
77
- export function nodeEnemy(key, dataOverride) {
78
- if (key in i18n(dataOverride).solNodes) {
79
- return i18n(dataOverride).solNodes[key].enemy;
80
- }
81
- if (key) {
82
- return key.split('/').slice(-1)[0];
83
- }
84
- return key;
85
- }
86
-
87
- /**
88
- *
89
- * @param {string} key - The data key
90
- * @param {string} dataOverride locale for use with translation
91
- * @returns {string} localization for language string
92
- */
93
- export function languageString(key, dataOverride) {
94
- const lowerKey = String(key).toLowerCase();
95
- if (lowerKey in i18n(dataOverride).languages) {
96
- return i18n(dataOverride).languages[lowerKey].value;
97
- }
98
- if (key in i18n(dataOverride).languages) {
99
- return i18n(dataOverride).languages[key].value;
100
- }
101
- if (key) {
102
- return toTitleCase(splitResourceName(String(key).split('/').slice(-1)[0]));
103
- }
104
- return key;
105
- }
106
-
107
- /**
108
- *
109
- * @param {string} key - The data key
110
- * @param {string} dataOverride locale for use with translation
111
- * @returns {string} localization for language description
112
- */
113
- export function languageDesc(key, dataOverride) {
114
- const lowerKey = String(key).toLowerCase();
115
- if (lowerKey in i18n(dataOverride).languages) {
116
- return i18n(dataOverride).languages[lowerKey].desc;
117
- }
118
- if (key in i18n(dataOverride).languages) {
119
- return i18n(dataOverride).languages[key].desc;
120
- }
121
- if (key) {
122
- return `[PH] ${toTitleCase(splitResourceName(String(key).split('/').slice(-1)[0]))} Desc`;
123
- }
124
- return key;
125
- }
126
-
127
- /**
128
- *
129
- * @param {string} key - The data key
130
- * @param {string} dataOverride locale for use with translation
131
- * @returns {string} translation for mission type
132
- */
133
- export function missionType(key, dataOverride) {
134
- if (key in i18n(dataOverride).missionTypes) {
135
- return i18n(dataOverride).missionTypes[key].value;
136
- }
137
- if (key) {
138
- return toTitleCase(key.replace(/^MT_/, ''));
139
- }
140
- return key;
141
- }
142
-
143
- /**
144
- *
145
- * @param {string} key - The data key
146
- * @param {string} dataOverride locale for use with translation
147
- * @returns {string} conclave mode
148
- */
149
- export function conclaveMode(key, dataOverride) {
150
- if (key in i18n(dataOverride).conclave.modes) {
151
- return i18n(dataOverride).conclave.modes[key].value;
152
- }
153
- return key;
154
- }
155
-
156
- /**
157
- *
158
- * @param {string} key - The data key
159
- * @param {string} dataOverride locale for use with translation
160
- * @returns {string} conclave category
161
- */
162
- export function conclaveCategory(key, dataOverride) {
163
- if (key in i18n(dataOverride).conclave.categories) {
164
- return i18n(dataOverride).conclave.categories[key].value;
165
- }
166
- return key;
167
- }
168
-
169
- /**
170
- *
171
- * @param {string} key - The data key
172
- * @param {string} dataOverride locale for use with translation
173
- * @returns {string} fissure modifier data
174
- */
175
- export function fissureModifier(key, dataOverride) {
176
- if (key in i18n(dataOverride).fissureModifiers) {
177
- return i18n(dataOverride).fissureModifiers[key].value;
178
- }
179
- return key;
180
- }
181
-
182
- /**
183
- *
184
- * @param {string} key - The data key
185
- * @param {string} dataOverride locale for use with translation
186
- * @returns {number | string} fissure tier
187
- */
188
- export function fissureTier(key, dataOverride) {
189
- if (key in i18n(dataOverride).fissureModifiers) {
190
- return i18n(dataOverride).fissureModifiers[key].num;
191
- }
192
- return key;
193
- }
194
-
195
- /**
196
- *
197
- * @param {string} key - The data key
198
- * @param {string} dataOverride locale for use with translation
199
- * @returns {string} syndicate name
200
- */
201
- export function syndicate(key, dataOverride) {
202
- if (key in i18n(dataOverride).syndicates) {
203
- return i18n(dataOverride).syndicates[key].name;
204
- }
205
- return key;
206
- }
207
-
208
- /**
209
- *
210
- * @param {string} key - The data key
211
- * @param {string} dataOverride locale for use with translation
212
- * @returns {string} upgrade type
213
- */
214
- export function upgrade(key, dataOverride) {
215
- if (key in i18n(dataOverride).upgradeTypes) {
216
- return i18n(dataOverride).upgradeTypes[key].value;
217
- }
218
- return key;
219
- }
220
-
221
- /**
222
- *
223
- * @param {string} key - The data key
224
- * @param {string} dataOverride locale for use with translation
225
- * @returns {string} mathematical operation value
226
- */
227
- export function operation(key, dataOverride) {
228
- if (key in i18n(dataOverride).operationTypes) {
229
- return i18n(dataOverride).operationTypes[key].value;
230
- }
231
- return key;
232
- }
233
-
234
- /**
235
- *
236
- * @param {string} key - The data key
237
- * @param {string} dataOverride locale for use with translation
238
- * @returns {string} symbol of mathematical operation
239
- */
240
- export function operationSymbol(key, dataOverride) {
241
- if (key in i18n(dataOverride).operationTypes) {
242
- return i18n(dataOverride).operationTypes[key].symbol;
243
- }
244
- return key;
245
- }
246
-
247
- /**
248
- * @param {string} key - The data key
249
- * @param {string} dataOverride locale for use with translation
250
- * @returns {string} sortie boss name
251
- */
252
- export function sortieBoss(key, dataOverride) {
253
- if (key in i18n(dataOverride).sortie.bosses) {
254
- return i18n(dataOverride).sortie.bosses[key].name;
255
- }
256
- return key;
257
- }
258
-
259
- /**
260
- * @param {string} key - The data key
261
- * @param {string} dataOverride locale for use with translation
262
- * @returns {string} faction for a sortie based on the boss
263
- */
264
- export function sortieFaction(key, dataOverride) {
265
- if (key in i18n(dataOverride).sortie.bosses) {
266
- return i18n(dataOverride).sortie.bosses[key].faction;
267
- }
268
- return key;
269
- }
270
-
271
- /**
272
- *
273
- * @param {string} key - The data key
274
- * @param {string} dataOverride locale for use with translation
275
- * @returns {string} sortie modifier data
276
- */
277
- export function sortieModifier(key, dataOverride) {
278
- if (key in i18n(dataOverride).sortie.modifierTypes) {
279
- return i18n(dataOverride).sortie.modifierTypes[key];
280
- }
281
- return key;
282
- }
283
-
284
- /**
285
- * @param {string} key - The data key
286
- * @param {string} dataOverride locale for use with translation
287
- * @returns {string} sortie modifier description
288
- */
289
- export function sortieModDesc(key, dataOverride) {
290
- if (i18n(dataOverride).sortie.modifierDescriptions && key in i18n(dataOverride).sortie.modifierDescriptions) {
291
- return i18n(dataOverride).sortie.modifierDescriptions[key];
292
- }
293
- return key;
294
- }
295
-
296
- /**
297
- * Retrieve the localized region for a given key
298
- * @param {string} key - The region key
299
- * @param {string} dataOverride - The locale to use for translations
300
- * @returns {string} localized region name
301
- */
302
- export function region(key, dataOverride) {
303
- if (key && i18n(dataOverride).persistentEnemy.regions[key]) {
304
- return i18n(dataOverride).persistentEnemy.regions[key];
305
- }
306
- return key;
307
- }
308
-
309
- /**
310
- * Retrieve conclave challenge name for the given key and locale
311
- * @param {string} key key to retrieve
312
- * @param {string} dataOverride locale key override
313
- * @returns {string} - The conclave challenge name for the given key
314
- */
315
- export function conclaveChallenge(key, dataOverride) {
316
- const splitKey = String(key).split('/').slice(-1)[0];
317
-
318
- if (i18n(dataOverride).conclave?.challenges?.[splitKey]) {
319
- return i18n(dataOverride).conclave.challenges[splitKey];
320
- }
321
- return {
322
- title: toTitleCase(splitResourceName(splitKey)),
323
- description: toTitleCase(splitResourceName(splitKey)),
324
- standing: 0,
325
- };
326
- }
327
-
328
- /**
329
- * Get the steel path data for given key
330
- * @param {string} dataOverride - The locale to use for translations
331
- * @returns {string} - The steel path data for the given key
332
- */
333
- export function steelPath(dataOverride) {
334
- return (i18n(dataOverride) || /* istanbul ignore next */ data).steelPath;
335
- }
336
-
337
- /**
338
- * An object containing functions to convert in-game names to their localizations
339
- * @typedef {Record<string, Function>} Translator
340
- * @property {Function} faction - Converts faction names
341
- * @property {Function} node - Converts star map node names
342
- * @property {Function} nodeMissionType - Returns the mission type of given node
343
- * @property {Function} nodeEnemy - Returns the faction that controls a given node
344
- * @property {Function} languageString - Converts generic language strings
345
- * @property {Function} languageDesc - Converts generic language strings
346
- * and retrieves the description
347
- * @property {Function} missionType - Converts mission types
348
- * @property {Function} conclaveMode - Converts conclave modes
349
- * @property {Function} conclaveCategory - Converts conclave challenge categories
350
- * @property {Function} fissureModifier - Converts fissure mission modifiers
351
- * @property {Function} syndicate - Converts syndicate names
352
- * @property {Function} upgrade - Converts upgrade types
353
- * @property {Function} operation - Converts operation types
354
- * @property {Function} sortieBoss - Converts sortie boss names
355
- * @property {Function} sortieModifier - Converts sortie modifier types
356
- * @property {Function} sortieModDesc - Converts sortie modifier type descriptions
357
- * @property {Function} region - Converts persistent enemy region indicies
358
- * @property {Function} conclaveChallenge - Convert conclave identifiers into standing data
359
- * @property {Function} steelPath - Retrieve Steel Path rotation data for locale
360
- * @property {Function} toTitleCase - Format provided string as titlecase
361
- */
362
- export default {
363
- faction,
364
- node,
365
- nodeMissionType,
366
- nodeEnemy,
367
- languageString,
368
- languageDesc,
369
- missionType,
370
- conclaveMode,
371
- conclaveCategory,
372
- fissureModifier,
373
- fissureTier,
374
- syndicate,
375
- upgrade,
376
- operation,
377
- operationSymbol,
378
- sortieBoss,
379
- sortieModifier,
380
- sortieModDesc,
381
- sortieFaction,
382
- region,
383
- conclaveChallenge,
384
- steelPath,
385
- toTitleCase,
386
- };
@@ -1 +0,0 @@
1
- export function insist(thing: any, ...args: any[]): void;
@@ -1,36 +0,0 @@
1
- /**
2
- * @param {number} millis The number of milliseconds in the time delta
3
- * @returns {string} formatted time delta
4
- */
5
- export function timeDeltaToString(millis: number): string;
6
- /**
7
- * Returns the number of milliseconds between now and a given date
8
- * @param {Date} d The date from which the current time will be subtracted
9
- * @param {Function} [now] A function that returns the current UNIX time in milliseconds
10
- * @returns {number} The number of milliseconds after the given date to now
11
- */
12
- export function fromNow(d: Date, now?: Function): number;
13
- /**
14
- * Returns the number of milliseconds between a given date and now
15
- * @param {Date} d The date that the current time will be subtracted from
16
- * @param {Function} [now] A function that returns the current UNIX time in milliseconds
17
- * @returns {number} The number of milliseconds after now to the given date
18
- */
19
- export function toNow(d: Date, now?: Function): number;
20
- /**
21
- * Returns a new Date constructed from a worldState date object
22
- * @param {object} d The worldState date object
23
- * @returns {Date} parsed date from DE date format
24
- */
25
- export function parseDate(d: object): Date;
26
- declare namespace _default {
27
- export { timeDeltaToString };
28
- export { fromNow };
29
- export { toNow };
30
- export { parseDate };
31
- }
32
- export default _default;
33
- /**
34
- * An object containing functions to format dates and times
35
- */
36
- export type TimeDateFunctions = Record<string, Function>;
@@ -1,192 +0,0 @@
1
- /**
2
- * Rough Titlecase!
3
- * @param {string} str string to be titlecased
4
- * @returns {string} titlecased string
5
- */
6
- export function toTitleCase(str: string): string;
7
- /**
8
- * Utility function to split the resource name and return somewhat human-readable string
9
- * @param {string} str localization resource key
10
- * @returns {string} human-readable string
11
- */
12
- export function splitResourceName(str: string): string;
13
- /**
14
- *
15
- * @param {string} key - The data key
16
- * @param {string} dataOverride locale for use with translation
17
- * @returns {string} faction name
18
- */
19
- export function faction(key: string, dataOverride: string): string;
20
- /**
21
- *
22
- * @param {string} key - The data key
23
- * @param {string} dataOverride locale for use with translation
24
- * @returns {string} node name
25
- */
26
- export function node(key: string, dataOverride: string): string;
27
- /**
28
- *
29
- * @param {string} key - The data key
30
- * @param {string} dataOverride locale for use with translation
31
- * @returns {string} mission type of the node
32
- */
33
- export function nodeMissionType(key: string, dataOverride: string): string;
34
- /**
35
- *
36
- * @param {string} key - The data key
37
- * @param {string} dataOverride locale for use with translation
38
- * @returns {string} faction that controls the node
39
- */
40
- export function nodeEnemy(key: string, dataOverride: string): string;
41
- /**
42
- *
43
- * @param {string} key - The data key
44
- * @param {string} dataOverride locale for use with translation
45
- * @returns {string} localization for language string
46
- */
47
- export function languageString(key: string, dataOverride: string): string;
48
- /**
49
- *
50
- * @param {string} key - The data key
51
- * @param {string} dataOverride locale for use with translation
52
- * @returns {string} localization for language description
53
- */
54
- export function languageDesc(key: string, dataOverride: string): string;
55
- /**
56
- *
57
- * @param {string} key - The data key
58
- * @param {string} dataOverride locale for use with translation
59
- * @returns {string} translation for mission type
60
- */
61
- export function missionType(key: string, dataOverride: string): string;
62
- /**
63
- *
64
- * @param {string} key - The data key
65
- * @param {string} dataOverride locale for use with translation
66
- * @returns {string} conclave mode
67
- */
68
- export function conclaveMode(key: string, dataOverride: string): string;
69
- /**
70
- *
71
- * @param {string} key - The data key
72
- * @param {string} dataOverride locale for use with translation
73
- * @returns {string} conclave category
74
- */
75
- export function conclaveCategory(key: string, dataOverride: string): string;
76
- /**
77
- *
78
- * @param {string} key - The data key
79
- * @param {string} dataOverride locale for use with translation
80
- * @returns {string} fissure modifier data
81
- */
82
- export function fissureModifier(key: string, dataOverride: string): string;
83
- /**
84
- *
85
- * @param {string} key - The data key
86
- * @param {string} dataOverride locale for use with translation
87
- * @returns {number | string} fissure tier
88
- */
89
- export function fissureTier(key: string, dataOverride: string): number | string;
90
- /**
91
- *
92
- * @param {string} key - The data key
93
- * @param {string} dataOverride locale for use with translation
94
- * @returns {string} syndicate name
95
- */
96
- export function syndicate(key: string, dataOverride: string): string;
97
- /**
98
- *
99
- * @param {string} key - The data key
100
- * @param {string} dataOverride locale for use with translation
101
- * @returns {string} upgrade type
102
- */
103
- export function upgrade(key: string, dataOverride: string): string;
104
- /**
105
- *
106
- * @param {string} key - The data key
107
- * @param {string} dataOverride locale for use with translation
108
- * @returns {string} mathematical operation value
109
- */
110
- export function operation(key: string, dataOverride: string): string;
111
- /**
112
- *
113
- * @param {string} key - The data key
114
- * @param {string} dataOverride locale for use with translation
115
- * @returns {string} symbol of mathematical operation
116
- */
117
- export function operationSymbol(key: string, dataOverride: string): string;
118
- /**
119
- * @param {string} key - The data key
120
- * @param {string} dataOverride locale for use with translation
121
- * @returns {string} sortie boss name
122
- */
123
- export function sortieBoss(key: string, dataOverride: string): string;
124
- /**
125
- * @param {string} key - The data key
126
- * @param {string} dataOverride locale for use with translation
127
- * @returns {string} faction for a sortie based on the boss
128
- */
129
- export function sortieFaction(key: string, dataOverride: string): string;
130
- /**
131
- *
132
- * @param {string} key - The data key
133
- * @param {string} dataOverride locale for use with translation
134
- * @returns {string} sortie modifier data
135
- */
136
- export function sortieModifier(key: string, dataOverride: string): string;
137
- /**
138
- * @param {string} key - The data key
139
- * @param {string} dataOverride locale for use with translation
140
- * @returns {string} sortie modifier description
141
- */
142
- export function sortieModDesc(key: string, dataOverride: string): string;
143
- /**
144
- * Retrieve the localized region for a given key
145
- * @param {string} key - The region key
146
- * @param {string} dataOverride - The locale to use for translations
147
- * @returns {string} localized region name
148
- */
149
- export function region(key: string, dataOverride: string): string;
150
- /**
151
- * Retrieve conclave challenge name for the given key and locale
152
- * @param {string} key key to retrieve
153
- * @param {string} dataOverride locale key override
154
- * @returns {string} - The conclave challenge name for the given key
155
- */
156
- export function conclaveChallenge(key: string, dataOverride: string): string;
157
- /**
158
- * Get the steel path data for given key
159
- * @param {string} dataOverride - The locale to use for translations
160
- * @returns {string} - The steel path data for the given key
161
- */
162
- export function steelPath(dataOverride: string): string;
163
- declare namespace _default {
164
- export { faction };
165
- export { node };
166
- export { nodeMissionType };
167
- export { nodeEnemy };
168
- export { languageString };
169
- export { languageDesc };
170
- export { missionType };
171
- export { conclaveMode };
172
- export { conclaveCategory };
173
- export { fissureModifier };
174
- export { fissureTier };
175
- export { syndicate };
176
- export { upgrade };
177
- export { operation };
178
- export { operationSymbol };
179
- export { sortieBoss };
180
- export { sortieModifier };
181
- export { sortieModDesc };
182
- export { sortieFaction };
183
- export { region };
184
- export { conclaveChallenge };
185
- export { steelPath };
186
- export { toTitleCase };
187
- }
188
- export default _default;
189
- /**
190
- * An object containing functions to convert in-game names to their localizations
191
- */
192
- export type Translator = Record<string, Function>;