@elite-dangerous-plugin-framework/journal 0.20250914.0 → 0.20260201.1

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/index.js CHANGED
@@ -1,2 +1,16 @@
1
- function o(n){return JSON.parse(n)}function s(n){return JSON.parse(n,(r,e,{source:t})=>/^-?\d+$/.test(t??"")?BigInt(t):e)}export{s as parseWithBigInt,o as parseWithLossyIntegers};
2
- //# sourceMappingURL=index.js.map
1
+ // src/index.ts
2
+ function parseWithLossyIntegers(event) {
3
+ return JSON.parse(event);
4
+ }
5
+ function parseWithBigInt(event) {
6
+ return JSON.parse(event, (k, v, { source }) => {
7
+ const isInteger = /^-?\d+$/.test(source ?? "");
8
+ return isInteger ? BigInt(source) : v;
9
+ });
10
+ }
11
+ export {
12
+ parseWithLossyIntegers,
13
+ parseWithBigInt
14
+ };
15
+
16
+ //# debugId=961FDE029D2549BE64756E2164756E21
package/dist/index.js.map CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import type { JournalEvent, JournalEvent_BI } from \"./generated/index.js\";\n\n/**\n * Use this converter if you do not care about precision of numbers - primarily if you do not need to handle IDs (e.g. System Adresses).\n *\n * It will treat **any** number as a IEEE 754 64 bit Float. This way integers are precise up to 15 digits, which is not enough for IDs. In these cases,\n * use {@link parseWithBigInt} if large Integers matter.\n */\nexport function parseWithLossyIntegers(event: string): JournalEvent {\n return JSON.parse(event);\n}\n\n/**\n * Converts a Journal Entry to a Journal Event with *all* Integers replaced with BigInts.\n * An Item is considered an integer if it consists of at least one numerical (0..9), which can be prefixed by a `-`.\n * Trailing `.` or `.0` cause the item to be treated as a regular IEEE 754 64 bit Float.\n *\n * Use this if you need to work with System Addresses. Working with BigInt's is a bit more annoying as you cannot directly use some std library functions.\n */\nexport function parseWithBigInt(event: string): JournalEvent_BI {\n return JSON.parse(event, ((k: any, v: any, { source }: any) => {\n const isInteger = /^-?\\d+$/.test(source ?? \"\");\n return isInteger ? BigInt(source) : v;\n }) as any);\n}\n\nexport { type JournalEvent, type JournalEvent_BI };\n"],
5
- "mappings": "AAQO,SAASA,EAAuBC,EAA6B,CAClE,OAAO,KAAK,MAAMA,CAAK,CACzB,CASO,SAASC,EAAgBD,EAAgC,CAC9D,OAAO,KAAK,MAAMA,EAAQ,CAACE,EAAQC,EAAQ,CAAE,OAAAC,CAAO,IAChC,UAAU,KAAKA,GAAU,EAAE,EAC1B,OAAOA,CAAM,EAAID,CAC7B,CACX",
6
- "names": ["parseWithLossyIntegers", "event", "parseWithBigInt", "k", "v", "source"]
7
- }
4
+ "sourcesContent": [
5
+ "import type { JournalEvent, JournalEvent_BI } from \"./generated/index.js\";\n\n/**\n * Use this converter if you do not care about precision of numbers - primarily if you do not need to handle IDs (e.g. System Adresses).\n *\n * It will treat **any** number as a IEEE 754 64 bit Float. This way integers are precise up to 15 digits, which is not enough for IDs. In these cases,\n * use {@link parseWithBigInt} if large Integers matter.\n */\nexport function parseWithLossyIntegers(event: string): JournalEvent {\n return JSON.parse(event);\n}\n\n/**\n * Converts a Journal Entry to a Journal Event with *all* Integers replaced with BigInts.\n * An Item is considered an integer if it consists of at least one numerical (0..9), which can be prefixed by a `-`.\n * Trailing `.` or `.0` cause the item to be treated as a regular IEEE 754 64 bit Float.\n *\n * Use this if you need to work with System Addresses. Working with BigInt's is a bit more annoying as you cannot directly use some std library functions.\n */\nexport function parseWithBigInt(event: string): JournalEvent_BI {\n return JSON.parse(event, ((k: any, v: any, { source }: any) => {\n const isInteger = /^-?\\d+$/.test(source ?? \"\");\n return isInteger ? BigInt(source) : v;\n }) as any);\n}\n\nexport { type JournalEvent, type JournalEvent_BI };\n"
6
+ ],
7
+ "mappings": ";AAQO,SAAS,sBAAsB,CAAC,OAA6B;AAAA,EAClE,OAAO,KAAK,MAAM,KAAK;AAAA;AAUlB,SAAS,eAAe,CAAC,OAAgC;AAAA,EAC9D,OAAO,KAAK,MAAM,OAAQ,CAAC,GAAQ,KAAU,aAAkB;AAAA,IAC7D,MAAM,YAAY,UAAU,KAAK,UAAU,EAAE;AAAA,IAC7C,OAAO,YAAY,OAAO,MAAM,IAAI;AAAA,GAC7B;AAAA;",
8
+ "debugId": "961FDE029D2549BE64756E2164756E21",
9
+ "names": []
10
+ }