-
Notifications
You must be signed in to change notification settings - Fork 57
Typesets
Typesets normally contain dictionary of typeName => type
pairs, but they may also contain special config values that set some global options or modes for entire typeset.
As for now, such options are:
-
jBinary.littleEndian
- sets endianness for this format. -
jBinary.mimeType
- sets mime-type which should be used for saving data from this typeset (i.e., when callingtoURI
without argument).
jBinary provides special Repo for popular file formats and corresponding demos.
Using standard typesets is easy - just make require-like call to jBinary.Repo
async loader method.
You can call it with one typeset name:
jBinary.Repo('bmp', function (BMP) {
var binary = new jBinary(data, BMP);
});
Or with list of names:
jBinary.Repo(['tar', 'gzip'], function (TAR, GZIP) {
// your code goes here ;)
});
All the typesets that are already loaded, are stored inside jBinary.Repo
itself with upper-case names of typesets used as keys (like jBinary.Repo.BMP
).
If you know some popular format structure and can write own typeset, you're welcome to contribute!
Inside the Repo, there is also associations.js file which provides associations between typesets and corresponding file name extensions & mime types.
jBinary uses those associations for loading data from external sources when typeset is not specified explicitly.
If you want your typeset to be associated with special file extensions or some mime-types, simply add entry into descriptors
object in this file like:
var descriptors = {
// ...
tar: {
extensions: ['tar'],
mimeTypes: ['application/tar', 'application/x-tar', 'applicaton/x-gtar', 'multipart/x-tar']
}
};