Skip to content

Commit 127422c

Browse files
committed
Version bump; documented new pointer format
1 parent b798214 commit 127422c

File tree

10 files changed

+23
-11
lines changed

10 files changed

+23
-11
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,11 @@ In the following definitions, `type` means the binary type format.
601601
- If `valueIsNonNull`:
602602
- `value` - value serialized by `typeIfNonNull`
603603
- `PointerType`:
604-
- `index` of value in buffer (note: if buffer contains both a type and a value, this index is relative to the start of the value data) - 32-bit unsigned integer
604+
- `offset` - `flexInt`:
605+
- If this is the first instance of these value bytes in the write buffer, then `0`
606+
- Otherwise, ([position of first byte of `offset`] - [position of first byte of `offset` in the last instance of these value bytes])
607+
- If `offset` is `0` (i.e. this is the first instance):
608+
- Value serialized by `targetType`
605609

606610
## Versioning
607611
Versions will be of the form `x.y.z`. They are in the `semver` format:

compiled/download.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiled/upload-download.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiled/upload.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as base64 from 'base64-js'
22

3-
const VERSION = 11
3+
const VERSION = 12
44
const VERSION_BYTES = 2
55
const VERSION_BUFFER = new ArrayBuffer(VERSION_BYTES)
66
new DataView(VERSION_BUFFER).setUint16(0, VERSION)

dist/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
const base64 = require("base64-js");
4-
const VERSION = 11;
4+
const VERSION = 12;
55
const VERSION_BYTES = 2;
66
const VERSION_BUFFER = new ArrayBuffer(VERSION_BYTES);
77
new DataView(VERSION_BUFFER).setUint16(0, VERSION);

docs/index.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,15 @@ <h3 id="value">Value</h3>
721721
</ul>
722722
</li>
723723
<li><code>PointerType</code>:<ul>
724-
<li><code>index</code> of value in buffer (note: if buffer contains both a type and a value, this index is relative to the start of the value data) - 32-bit unsigned integer</li>
724+
<li><code>offset</code> - <code>flexInt</code>:<ul>
725+
<li>If this is the first instance of these value bytes in the write buffer, then <code>0</code></li>
726+
<li>Otherwise, ([position of first byte of <code>offset</code>] - [position of first byte of <code>offset</code> in the last instance of these value bytes])</li>
727+
</ul>
728+
</li>
729+
<li>If <code>offset</code> is <code>0</code> (i.e. this is the first instance):<ul>
730+
<li>Value serialized by <code>targetType</code></li>
731+
</ul>
732+
</li>
725733
</ul>
726734
</li>
727735
</ul>

docs/modules/_config_.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ <h2>Variables</h2>
8787
<section class="tsd-panel tsd-member tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported">
8888
<a name="version" class="tsd-anchor"></a>
8989
<h3>VERSION</h3>
90-
<div class="tsd-signature tsd-kind-icon">VERSION<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">11</span><span class="tsd-signature-symbol"> =&nbsp;11</span></div>
90+
<div class="tsd-signature tsd-kind-icon">VERSION<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">12</span><span class="tsd-signature-symbol"> =&nbsp;12</span></div>
9191
<aside class="tsd-sources">
9292
<ul>
9393
<li>Defined in config.ts:3</li>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "structure-bytes",
3-
"version": "15.0.2",
3+
"version": "16.0.0",
44
"description": "A library for more efficient data transfers by separating the structure from the values and storing each as binary data",
55
"main": "dist/index.js",
66
"dependencies": {

test/type-bytes/signature.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from '../../dist/lib/assert'
22
import * as t from '../../dist'
33

44
export = () => {
5-
assert.equal(new t.ByteType().getSignature(), 'AAs=S/USLzRFVMU73i67jNK349FgCtYxw4Wl18ziPHeFRZo=')
5+
assert.equal(new t.ByteType().getSignature(), 'AAw=S/USLzRFVMU73i67jNK349FgCtYxw4Wl18ziPHeFRZo=')
66
const type = new t.StructType({
77
bcd: new t.PointerType(
88
new t.OptionalType(
@@ -21,5 +21,5 @@ export = () => {
2121
)
2222
})
2323
assert.equal(type.getHash(), 'YwJi4ZvHdopqQNW0lf2i8zQ37DEDMWmT9gFoqInimHw=')
24-
assert.equal(type.getSignature(), 'AAs=YwJi4ZvHdopqQNW0lf2i8zQ37DEDMWmT9gFoqInimHw=')
24+
assert.equal(type.getSignature(), 'AAw=YwJi4ZvHdopqQNW0lf2i8zQ37DEDMWmT9gFoqInimHw=')
2525
}

0 commit comments

Comments
 (0)