@etothepii/satisfactory-file-parser
Advanced tools
Comparing version 0.4.10 to 0.4.11
@@ -175,3 +175,3 @@ "use strict"; | ||
const recipeTypePath = reader.readString(); | ||
reader.readInt64(); | ||
const blueprintProxy = ObjectReference_1.ObjectReference.read(reader); | ||
instances.push({ | ||
@@ -184,2 +184,3 @@ transform, | ||
patternPath, | ||
blueprintProxy | ||
}); | ||
@@ -388,3 +389,3 @@ } | ||
writer.writeString(instance.recipeTypePath); | ||
writer.writeInt64(0n); | ||
ObjectReference_1.ObjectReference.write(writer, instance.blueprintProxy); | ||
} | ||
@@ -391,0 +392,0 @@ } |
@@ -45,2 +45,3 @@ import { Transform, vec2, vec3 } from '../../../structs/util.types'; | ||
patternPath: string; | ||
blueprintProxy: ObjectReference; | ||
}; | ||
@@ -47,0 +48,0 @@ export type BuildableSubsystemSpecialProperty = { |
{ | ||
"name": "@etothepii/satisfactory-file-parser", | ||
"author": "etothepii", | ||
"version": "0.4.10", | ||
"version": "0.4.11", | ||
"description": "A file parser for satisfactory files. Includes save files and blueprint files.", | ||
@@ -6,0 +6,0 @@ "types": "./build/index.d.ts", |
@@ -21,3 +21,3 @@ # Satisfactory File Parser | ||
| U8 | ✅ 0.1.20 - 0.3.7 | | ||
| U1.0 | ✅ >= 0.4.10 | | ||
| U1.0 | ✅ >= 0.4.11 | | ||
@@ -29,3 +29,3 @@ | ||
## Usage of Save Parsing | ||
Usage of the SaveParser is easy. For reading a save file (`.sav`), just pass a Buffer to the parser with the file content. | ||
For reading a save file (`.sav`), just pass a Buffer to the parser with the file content. | ||
```js | ||
@@ -39,4 +39,29 @@ import * as fs from 'fs'; | ||
### Save Parsing via Stream | ||
You can parse via stream, to save RAM. The binary data will still be in memory, but the converted JSON won't. | ||
The returned `stream` is a readable WHATWG stream of type string. | ||
WHATWG is used by default by browsers. Node js can use them using `Writable.toWeb()` and `Writable.fromWeb()` for example. | ||
```js | ||
const jsonFileStream = fs.createWriteStream(outJsonPath, { highWaterMark: 1024 * 1024 * 200 }); // your outgoing JSON stream. In this case directly to file. | ||
const whatwgWriteStream = Writable.toWeb(outJsonStream) as WritableStream<string>; // convert the file stream to WHATWG-compliant stream | ||
const { stream, startStreaming } = ReadableStreamParser.CreateReadableStreamFromSaveToJson(savename, file, decompressedBody => { | ||
console.log('on binary body data.'); | ||
}, (progress: number, msg: string | undefined) => { | ||
// a callback for reporting progress as number [0,1]. Sometimes has a message. | ||
console.log(`${new Date().toString()}: progress`, progress, msg); | ||
}); | ||
stream.pipeTo(whatwgWriteStream); | ||
whatwgWriteStream.on('close', () => { | ||
// write stream finished | ||
}); | ||
startStreaming(); | ||
``` | ||
Consequently, writing a parsed save file back is just as easy. | ||
The SaveParser has callbacks to assist in syncing on different occasions during the process. | ||
The SaveParser has callbacks to assist during syncing on different occasions during the process. | ||
For example, when writing the header or when writing a chunk of the save body. | ||
@@ -43,0 +68,0 @@ The splitting in individual chunks enables you to more easily stream the binary data to somewhere else. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
658725
12207
141