Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeux committed Dec 2, 2011
1 parent bebb972 commit b2ae3fe
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jParser methods:
* **skip(count)**: Advance in the file by ``count`` bytes.
* **seek(position)**: Go to ``position``.
* **seek(position, callback)**: Go to ``position``, execute the ``callback`` and return to the previous position.
* **current**: The current object being parsed. See it as a way to use what has been parsed just before.

jParser constructor:

Expand Down Expand Up @@ -97,7 +98,21 @@ string0: function (length) {
}
```

**Control 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.
**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.

```javascript
image: {
width: 'uint8',
height: 'uint8',
pixels: [
'array',
['array', 'rgba', function () { return this.current.width; }],
function () { return this.current.height; }
]
}
```

**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.

```javascript
entryHeader: {
Expand Down Expand Up @@ -128,6 +143,8 @@ file: {
}
```



Caveats
=======

Expand Down

0 comments on commit b2ae3fe

Please sign in to comment.