API Docs for:
Show:

LS.WBin Class

Module: LS

WBin allows to create binary files easily (similar to WAD format). You can pack lots of resources in one file or extract them.

Methods

WBin.create

(
  • origin
  • origin_class_name
)
Uint8Array

Builds a WBin data stream from an object (every property of the object will be considered a lump with data) It supports Numbers, Strings and TypedArrays or ArrayBuffer

Parameters:

  • origin Object

    object containing all the lumps, the key will be used as lump name

  • origin_class_name String

    [Optional] allows to add a classname to the WBin, this is used to detect which class to instance when extracting it

Returns:

Uint8Array:

all the bytes

WBin.getHeaderInfo

(
  • data_array
)
Object

Extract the header info from an ArrayBuffer (it contains version, and lumps info)

Parameters:

  • data_array UInt8Array

Returns:

Object:

Header

WBin.isWBin

(
  • data
)
Boolean

Allows to check if one Uint8Array contains a WBin file

Parameters:

  • data UInt8Array

Returns:

Boolean:

WBin.load

(
  • data_array
  • skip_classname
  • filename
)

Extract the info from a Uint8Array containing WBin info and returns the object with all the lumps. If the data contains info about the class to instantiate, the WBin instantiates the class and passes the data to it

Parameters:

  • data_array UInt8Array
  • skip_classname Bool

    avoid getting the instance of the class specified in classname, and get only the lumps

  • filename String

    [optional] the filename where this wbin came from (important to mark resources)

Returns:

:

Could be an Object with all the lumps or an instance to the class specified in the WBin data