@etothepii/satisfactory-file-parser 0.0.16 → 0.0.17

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 (2) hide show
  1. package/README.md +49 -11
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -19,13 +19,15 @@ If there will be changes, those will come very soon as soon as U8 is out on Expe
19
19
 
20
20
  ## Installation via npm
21
21
  `npm install @etothepii/satisfactory-file-parser`
22
- ## Usage
23
- Usage of the SaveParser is easy. For reading a save file, just pass a Buffer to it.
22
+
23
+ ## Usage of Save Parsing
24
+ Usage of the SaveParser is easy. For reading a save file (`.sav`), just pass a Buffer to the parser with the file content.
24
25
  ```js
25
- import { SaveParser } from "@etothepii/satisfactory-file-parser";
26
+ import * as fs from 'fs';
27
+ import { Parser } from "@etothepii/satisfactory-file-parser";
26
28
 
27
29
  const file = fs.readFileSync('./MySave.sav') as Buffer;
28
- const parsedSave = SaveParser.ParseSaveFile(file);
30
+ const parsedSave = Parser.ParseSaveFile(file);
29
31
  ```
30
32
 
31
33
  Consequently, writing a parsed save file back is just as easy.
@@ -33,21 +35,57 @@ The SaveParser has callbacks to assist in syncing on different occasions during
33
35
  For example, when writing the header or when writing a chunk of the save body.
34
36
  The splitting in individual chunks enables you to more easily stream the binary data to somewhere else.
35
37
  ```js
36
- import { SaveParser } from "@etothepii/satisfactory-file-parser";
38
+ import * as fs from 'fs';
39
+ import { Parser } from "@etothepii/satisfactory-file-parser";
37
40
 
38
- let header, bodyChunks;
39
- SaveParser.WriteSave(save, binaryBeforeCompressed => {}, header => {
41
+ let header, bodyChunks = [];
42
+ Parser.WriteSave(save, binaryBeforeCompressed => {
43
+ console.log('on binary data before being compressed.');
44
+ }, header => {
40
45
  console.log('on save header.');
41
46
  header = header;
42
47
  }, chunk => {
43
48
  console.log('on save body chunk.');
44
49
  bodyChunks.push(chunk);
45
- }, summary => {
46
- console.log('finished writing chunks.');
50
+ });
51
+
52
+ // write complete sav file back to disk
53
+ fs.writeFileSync('./MyModifiedSave.sav', Buffer.concat([header, ...bodyChunks]));
54
+ ```
55
+
56
+ ## Usage of Blueprint Parsing
57
+ Blueprint parsing works very similiar. Note, that blueprints consist of 2 files. The `.sbp` main file and the config file `.sbpcfg`.
58
+
59
+ ```js
60
+ import * as fs from 'fs';
61
+ import { Parser } from "@etothepii/satisfactory-file-parser";
47
62
 
48
- // write complete sav file back to disk
49
- fs.writeFileSync('./MyModifiedSave.sav', Buffer.concat([header, ...bodyChunks]));
63
+ const mainFile = fs.readFileSync('./MyBlueprint.sbp') as Buffer;
64
+ const configFile = fs.readFileSync('./MyBlueprint.sbpcfg') as Buffer;
65
+ const parsedBlueprint = Parser.ParseBlueprintFiles('MyBlueprint', mainFile, configFile);
66
+ ```
67
+
68
+ Consequently, writing a blueprint into binary data works the same way with getting callbacks in the same style as the save parsing.
69
+ ```js
70
+ import * as fs from 'fs';
71
+ import { Parser } from "@etothepii/satisfactory-file-parser";
72
+
73
+ let mainFileHeader, mainFileBodyChunks = [];
74
+ const summary = Parser.WriteBlueprintFiles(blueprint, mainFileBinaryBeforeCompressed => {
75
+ console.log('on main file binary data before being compressed.');
76
+ }, header => {
77
+ console.log('on main file blueprint header.');
78
+ mainFileHeader = header;
79
+ }, chunk => {
80
+ console.log('on main file blueprint body chunk.');
81
+ mainFileBodyChunks.push(chunk);
50
82
  });
83
+
84
+ // write complete .sbp file back to disk
85
+ fs.writeFileSync('./MyModifiedBlueprint.sbp', Buffer.concat([mainFileHeader, ...mainFileBodyChunks]));
86
+
87
+ // write .sbpcfg file back to disk, we get that data from the result of WriteBlueprint
88
+ fs.writeFileSync('./MyModifiedSave.sbpcfg', Buffer.from(summary.configFileBinary));
51
89
  ```
52
90
 
53
91
  ## License
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@etothepii/satisfactory-file-parser",
3
3
  "author": "etothepii",
4
- "version": "0.0.16",
4
+ "version": "0.0.17",
5
5
  "description": "A file parser for satisfactory files. Includes save files and blueprint files.",
6
6
  "module": "Node16",
7
7
  "typings": "./build/index.d.ts",