Реклама
GitHub - Vjeux/jParser: Parsing Binary Files Made Easy
28-09-2022, 21:12 | Автор: BOWJoshua0 | Категория: Мультимедиа
Pocketoption unleash the power of binary options.
jParser - Parsing binary files made easy.
jParser makes it easy to parse binary files in javascript.
You write the structure once, it gets parsed automatically. The parsing process can be extended with custom functions. It allows to parse non trivial files with ease. It works both in the browser and NodeJS as it is powered by jDataView.
Unsigned Int : uint8, uint16, uint32 Signed Int : int8, int16, int32 Float : float32, float64 String : char, string(len) Array : array(type, len) BitField : (bitCount) Position : tell, skip(len), seek(pos), seek(pos, Binary Options func) Conditionals : if(predicate, type)
parse(value) : Run the parsing, can be used recursively. Number : Reads bitfield of given length in left-to-right mode and returns them as unsigned integer (so you can work with them using simple javascript binary operators). Please note that you can mix bitfields with primitive and complex types in one structure or even use them in own functions, but ALWAYS make sure that consecutive bitfields are padded to integer byte count (or 8*N bit count ) before reading any other data types; most popular data formats already follow this rule but better to check out when writing own structures if you don't want to get unexpected behavior. Function : Calls the function. String : Binary Options Dereferences the value in the structure. Array : Function call, the function is the first element and arguments are the following. Object : Returns an object with the same keys and parses the values.
new jParser(data, structure) data is a jDataView. You can give pretty much anything (String, ArrayBuffer, Node Buffer), it will be casted to jDataView automatically. structure is an object with all the defined structures.
Basic C Structure You have the ability to define C-like structures. It's a javascript object where keys are labels and values are types.
References Structures can reference other structures. Use structure name within a string in order to reference it. The following is an example from World of Warcraft model files.
Helpers It is really easy to make new primitive types. You can either use existing constructions such as objects ( float3 ) or arrays ( float4 ). In case you want to do something more complicated, you always have the option to define a new function and use this.parse to keep parsing ( hex32 , string0 ).
Back Reference Instead of using an integer for the array size, you can put a function that will return an integer. In this function, you can use this.current to reference the englobing object being parsed.
Advanced Parsing The best part of jParser is that complicated parsing logic can be expressed within the structure. It allows to parse complex files without having to split structure from parsing code.
NodeJS : Just use npm to install jParser and you are set :)
Browser : I've patched jQuery to allow to download binary files using the best binary format. You include this patched jQuery, jDataView and jParser and you are set :)
This tool works thanks to a feature that is not in the javascript specification: When you iterate over an object keys, the keys will be listed in their order of insertion. Note that Chrome and Opera do not respect this implicit rule for keys that are numbers.
If you follow those two rules, binary options the library will work in all the current javascript implementations.
Do not start a key name with a digit Do not put the same key twice in the same object.
ICO Parser . This is a basic example to parse a binary file in NodeJS. It shows how to solve many common issues with binary file parsing.
ico.js : jParser structure. : parsed file.
Tar Extractor .GitHub - Vjeux/jParser: Parsing Binary Files Made Easy This is a basic example to parse a binary file in the browser.GitHub - Vjeux/jParser: Parsing Binary Files Made Easy
tar.html : jParser structure.
World of Warcraft Model Viewer. It uses jParser to read the binary model and then WebGL to display it.
Скачать Skymonk по прямой ссылке
Просмотров: 15  |  Комментариев: (0)
Уважаемый посетитель, Вы зашли на сайт kopirki.net как незарегистрированный пользователь.
Мы рекомендуем Вам зарегистрироваться либо войти на сайт под своим именем.