import { PlugyPage , PlugyStash } from "../types" ; import { SaveFileReader } from "../../save-file/SaveFileReader" ; import { parseItemList } from "../../items/parsing/parseItemList" ; export function parsePage ( reader , stash ) { const header = reader . readString ( 2 ) ; if ( header !== "ST" ) { throw new Error ( `Unexpected header ${ header } for a stash page` ) ; } reader . peek = true ; reader . readNullTerminatedString ( ) ; reader . read ( 1 ) ; const hasFlags = reader . readString ( 2 ) !== "JM" ; reader . peek = false ; let flags ; if ( hasFlags ) { flags = reader . readInt8 ( ) ; reader . read ( 3 ) ; } return { flags , name : reader . readNullTerminatedString ( ) , items : parseItemList ( reader , stash ) , } ; }