Skip to content

Commit

Permalink
fixes #7: allow arbitrary uint for extension point
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed Feb 24, 2017
1 parent 6a76691 commit 4d45a00
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions README.md
Expand Up @@ -422,17 +422,18 @@ Boolean-valued map literal, for implementations which do not use repeated keyset

#### extension\*

+--------+--------+~~~~~~+======+
| 0xFF |xxxxxxxx| uint | data |
+--------+--------+~~~~~~+======+
+--------+~~~~~~+~~~~~~+======+
| 0xFF | uint | uint | data |
+--------+~~~~~~+~~~~~~+======+

Specifies an extension type tag `xxxxxxxx`, followed by a `uint` length, followed by zero or more bytes of data.
Specifies a `uint` extension point, followed by a `uint` length, followed by a number of bytes of data matching the length.

Encoders are expected to provide an interface for a consumer to specify a serialisation and deserialisation mechanism for a given type of data.

```js
SuperPackTranscoder.extend(
// extension point: 0 through 127
let transcoder = new SuperPackTranscoder;
transcoder.extend(
// extension point
0,
// detect values which require this custom serialisation
x => x instanceof RegExp,
Expand All @@ -443,11 +444,6 @@ SuperPackTranscoder.extend(
);
```

The extension ranges are reserved as follows:

* Extension points 0-127 are available for user-specified extension types.
* Extension points 128-255 are currently reserved for future spec additions.


## Optimisations

Expand Down

0 comments on commit 4d45a00

Please sign in to comment.