Skip to content

Commit f9b7468

Browse files
committed
Fixed #58
1 parent 106fc3c commit f9b7468

File tree

66 files changed

+2086
-1514
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2086
-1514
lines changed

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.

dist/lib/appendable.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default abstract class AppendableBuffer {
5454
* .pause()
5555
* .add(4).add(5).add(6)
5656
* .reset() //cancels [4, 5, 6]
57-
* .resume()
57+
* .resume() //resumes []
5858
* .resume() //resumes [1, 2, 3]
5959
* console.log(new Uint8Array(gb.toBuffer())) //Uint8Array [ 1, 2, 3 ]
6060
* ````

dist/recursive-registry.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ import { RegisterableType, TypeAndName } from './recursive-registry-type';
1313
* If you need to use a different type, wrap it
1414
* in a single-field [[StructType]].
1515
*
16+
* THIS METHOD OF REGISTERING RECURSIVE TYPES HAS BEEN DEPRECATED.
17+
* Instead, please use [[RecursiveType.setType]]:
18+
* ````javascript
19+
* //A binary tree of unsigned bytes
20+
* let treeType = new sb.RecursiveType('tree-node')
21+
* treeType.setType(new sb.StructType({
22+
* left: new sb.OptionalType(treeType),
23+
* value: new sb.UnsignedByteType,
24+
* right: new sb.OptionalType(treeType)
25+
* }))
26+
* ````
27+
*
1628
* Example:
1729
* ````javascript
1830
* //A binary tree of unsigned bytes

dist/recursive-registry.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ const registeredTypes = new Map();
2222
* If you need to use a different type, wrap it
2323
* in a single-field [[StructType]].
2424
*
25+
* THIS METHOD OF REGISTERING RECURSIVE TYPES HAS BEEN DEPRECATED.
26+
* Instead, please use [[RecursiveType.setType]]:
27+
* ````javascript
28+
* //A binary tree of unsigned bytes
29+
* let treeType = new sb.RecursiveType('tree-node')
30+
* treeType.setType(new sb.StructType({
31+
* left: new sb.OptionalType(treeType),
32+
* value: new sb.UnsignedByteType,
33+
* right: new sb.OptionalType(treeType)
34+
* }))
35+
* ````
36+
*
2537
* Example:
2638
* ````javascript
2739
* //A binary tree of unsigned bytes

dist/types/recursive.d.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,29 @@ export default class RecursiveType<E, READ_E extends E = E> extends AbsoluteType
120120
writeValue(buffer: AppendableBuffer, value: E): void;
121121
consumeValue(buffer: ArrayBuffer, offset: number): ReadResult<READ_E>;
122122
equals(otherType: any): boolean;
123+
/**
124+
* An alternative to [[registerType]],
125+
* to avoid writing the type's name twice.
126+
* Please use this instead of [[registerType]].
127+
*
128+
* So this
129+
* ````javascript
130+
* let type = new sb.RecursiveType('abc')
131+
* sb.registerType({
132+
* type: new sb.StructType({
133+
* //...
134+
* }),
135+
* name: 'abc'
136+
* })
137+
* ````
138+
* becomes
139+
* ````javascript
140+
* let type = new sb.RecursiveType('abc')
141+
* type.setType(new sb.StructType({
142+
* //...
143+
* }))
144+
* ````
145+
* @param type The type to register
146+
*/
147+
setType(type: RegisterableType): void;
123148
}

dist/types/recursive.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,5 +213,32 @@ class RecursiveType extends absolute_1.default {
213213
return super.equals(otherType)
214214
&& this.name === otherType.name;
215215
}
216+
/**
217+
* An alternative to [[registerType]],
218+
* to avoid writing the type's name twice.
219+
* Please use this instead of [[registerType]].
220+
*
221+
* So this
222+
* ````javascript
223+
* let type = new sb.RecursiveType('abc')
224+
* sb.registerType({
225+
* type: new sb.StructType({
226+
* //...
227+
* }),
228+
* name: 'abc'
229+
* })
230+
* ````
231+
* becomes
232+
* ````javascript
233+
* let type = new sb.RecursiveType('abc')
234+
* type.setType(new sb.StructType({
235+
* //...
236+
* }))
237+
* ````
238+
* @param type The type to register
239+
*/
240+
setType(type) {
241+
recursiveRegistry.registerType({ type, name: this.name });
242+
}
216243
}
217244
exports.default = RecursiveType;

docs/interfaces/_lib_appendable_.appendablebuffer.html renamed to docs/classes/_lib_appendable_.appendablebuffer.html

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<a href="_lib_appendable_.appendablebuffer.html">AppendableBuffer</a>
6363
</li>
6464
</ul>
65-
<h1>Interface AppendableBuffer</h1>
65+
<h1>Class AppendableBuffer</h1>
6666
</div>
6767
</div>
6868
</header>
@@ -74,8 +74,8 @@ <h1>Interface AppendableBuffer</h1>
7474
<div class="lead">
7575
<p>A &quot;writable&quot; interface, sufficient
7676
to be able to write type and value bytes.
77-
Implemented by <a href="../classes/_lib_growable_buffer_.growablebuffer.html">GrowableBuffer</a>, as well as
78-
<a href="../classes/_lib_appendable_stream_.appendablestream.html">AppendableStream</a> (a wrapper around a writable stream).
77+
Implemented by <a href="_lib_growable_buffer_.growablebuffer.html">GrowableBuffer</a>, as well as
78+
<a href="_lib_appendable_stream_.appendablestream.html">AppendableStream</a> (a wrapper around a writable stream).
7979
All methods can be chained, e.g.</p>
8080
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> gb = <span class="hljs-keyword">new</span> GrowableBuffer
8181
gb
@@ -95,42 +95,43 @@ <h3>Hierarchy</h3>
9595
<ul class="tsd-hierarchy">
9696
<li>
9797
<span class="target">AppendableBuffer</span>
98+
<ul class="tsd-hierarchy">
99+
<li>
100+
<a href="_lib_growable_buffer_.growablebuffer.html" class="tsd-signature-type">GrowableBuffer</a>
101+
</li>
102+
<li>
103+
<a href="_lib_appendable_stream_.appendablestream.html" class="tsd-signature-type">AppendableStream</a>
104+
</li>
105+
</ul>
98106
</li>
99107
</ul>
100108
</section>
101-
<section class="tsd-panel">
102-
<h3>Implemented by</h3>
103-
<ul class="tsd-hierarchy">
104-
<li><a href="../classes/_lib_appendable_stream_.appendablestream.html" class="tsd-signature-type">AppendableStream</a></li>
105-
<li><a href="../classes/_lib_growable_buffer_.growablebuffer.html" class="tsd-signature-type">GrowableBuffer</a></li>
106-
</ul>
107-
</section>
108109
<section class="tsd-panel-group tsd-index-group">
109110
<h2>Index</h2>
110111
<section class="tsd-panel tsd-index-panel">
111112
<div class="tsd-index-content">
112113
<section class="tsd-index-section tsd-is-external">
113114
<h3>Properties</h3>
114115
<ul class="tsd-index-list">
115-
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-external"><a href="_lib_appendable_.appendablebuffer.html#length" class="tsd-kind-icon">length</a></li>
116+
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-external"><a href="_lib_appendable_.appendablebuffer.html#length" class="tsd-kind-icon">length</a></li>
116117
</ul>
117118
</section>
118119
<section class="tsd-index-section tsd-is-external">
119120
<h3>Methods</h3>
120121
<ul class="tsd-index-list">
121-
<li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_lib_appendable_.appendablebuffer.html#add" class="tsd-kind-icon">add</a></li>
122-
<li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_lib_appendable_.appendablebuffer.html#addall" class="tsd-kind-icon">add<wbr>All</a></li>
123-
<li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_lib_appendable_.appendablebuffer.html#pause" class="tsd-kind-icon">pause</a></li>
124-
<li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_lib_appendable_.appendablebuffer.html#reset" class="tsd-kind-icon">reset</a></li>
125-
<li class="tsd-kind-method tsd-parent-kind-interface tsd-is-external"><a href="_lib_appendable_.appendablebuffer.html#resume" class="tsd-kind-icon">resume</a></li>
122+
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="_lib_appendable_.appendablebuffer.html#add" class="tsd-kind-icon">add</a></li>
123+
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="_lib_appendable_.appendablebuffer.html#addall" class="tsd-kind-icon">add<wbr>All</a></li>
124+
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="_lib_appendable_.appendablebuffer.html#pause" class="tsd-kind-icon">pause</a></li>
125+
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="_lib_appendable_.appendablebuffer.html#reset" class="tsd-kind-icon">reset</a></li>
126+
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-external"><a href="_lib_appendable_.appendablebuffer.html#resume" class="tsd-kind-icon">resume</a></li>
126127
</ul>
127128
</section>
128129
</div>
129130
</section>
130131
</section>
131132
<section class="tsd-panel-group tsd-member-group tsd-is-external">
132133
<h2>Properties</h2>
133-
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-external">
134+
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-external">
134135
<a name="length" class="tsd-anchor"></a>
135136
<h3>length</h3>
136137
<div class="tsd-signature tsd-kind-icon">length<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
@@ -148,10 +149,10 @@ <h3>length</h3>
148149
</section>
149150
<section class="tsd-panel-group tsd-member-group tsd-is-external">
150151
<h2>Methods</h2>
151-
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external">
152+
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
152153
<a name="add" class="tsd-anchor"></a>
153154
<h3>add</h3>
154-
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external">
155+
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
155156
<li class="tsd-signature tsd-kind-icon">add<span class="tsd-signature-symbol">(</span>value<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">this</span></li>
156157
</ul>
157158
<ul class="tsd-descriptions">
@@ -180,10 +181,10 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">this</spa
180181
</li>
181182
</ul>
182183
</section>
183-
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external">
184+
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
184185
<a name="addall" class="tsd-anchor"></a>
185186
<h3>add<wbr>All</h3>
186-
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external">
187+
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
187188
<li class="tsd-signature tsd-kind-icon">add<wbr>All<span class="tsd-signature-symbol">(</span>buffer<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">ArrayBuffer</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">this</span></li>
188189
</ul>
189190
<ul class="tsd-descriptions">
@@ -214,10 +215,10 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">this</spa
214215
</li>
215216
</ul>
216217
</section>
217-
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external">
218+
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
218219
<a name="pause" class="tsd-anchor"></a>
219220
<h3>pause</h3>
220-
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external">
221+
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
221222
<li class="tsd-signature tsd-kind-icon">pause<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">this</span></li>
222223
</ul>
223224
<ul class="tsd-descriptions">
@@ -246,7 +247,7 @@ <h3>pause</h3>
246247
.pause()
247248
.add(<span class="hljs-number">4</span>).add(<span class="hljs-number">5</span>).add(<span class="hljs-number">6</span>)
248249
.reset() <span class="hljs-comment">//cancels [4, 5, 6]</span>
249-
.resume()
250+
.resume() <span class="hljs-comment">//resumes []</span>
250251
.resume() <span class="hljs-comment">//resumes [1, 2, 3]</span>
251252
<span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">new</span> <span class="hljs-built_in">Uint8Array</span>(gb.toBuffer())) <span class="hljs-comment">//Uint8Array [ 1, 2, 3 ]</span>
252253
</code></pre>
@@ -255,10 +256,10 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">this</spa
255256
</li>
256257
</ul>
257258
</section>
258-
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external">
259+
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
259260
<a name="reset" class="tsd-anchor"></a>
260261
<h3>reset</h3>
261-
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external">
262+
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
262263
<li class="tsd-signature tsd-kind-icon">reset<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">this</span></li>
263264
</ul>
264265
<ul class="tsd-descriptions">
@@ -286,10 +287,10 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">this</spa
286287
</li>
287288
</ul>
288289
</section>
289-
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface tsd-is-external">
290+
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-external">
290291
<a name="resume" class="tsd-anchor"></a>
291292
<h3>resume</h3>
292-
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-external">
293+
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-external">
293294
<li class="tsd-signature tsd-kind-icon">resume<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">this</span></li>
294295
</ul>
295296
<ul class="tsd-descriptions">
@@ -332,25 +333,25 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">this</spa
332333
<ul class="before-current">
333334
</ul>
334335
<ul class="current">
335-
<li class="current tsd-kind-interface tsd-parent-kind-external-module tsd-is-external">
336+
<li class="current tsd-kind-class tsd-parent-kind-external-module tsd-is-external">
336337
<a href="_lib_appendable_.appendablebuffer.html" class="tsd-kind-icon">Appendable<wbr>Buffer</a>
337338
<ul>
338-
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-external">
339+
<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-external">
339340
<a href="_lib_appendable_.appendablebuffer.html#length" class="tsd-kind-icon">length</a>
340341
</li>
341-
<li class=" tsd-kind-method tsd-parent-kind-interface tsd-is-external">
342+
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
342343
<a href="_lib_appendable_.appendablebuffer.html#add" class="tsd-kind-icon">add</a>
343344
</li>
344-
<li class=" tsd-kind-method tsd-parent-kind-interface tsd-is-external">
345+
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
345346
<a href="_lib_appendable_.appendablebuffer.html#addall" class="tsd-kind-icon">add<wbr>All</a>
346347
</li>
347-
<li class=" tsd-kind-method tsd-parent-kind-interface tsd-is-external">
348+
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
348349
<a href="_lib_appendable_.appendablebuffer.html#pause" class="tsd-kind-icon">pause</a>
349350
</li>
350-
<li class=" tsd-kind-method tsd-parent-kind-interface tsd-is-external">
351+
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
351352
<a href="_lib_appendable_.appendablebuffer.html#reset" class="tsd-kind-icon">reset</a>
352353
</li>
353-
<li class=" tsd-kind-method tsd-parent-kind-interface tsd-is-external">
354+
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-external">
354355
<a href="_lib_appendable_.appendablebuffer.html#resume" class="tsd-kind-icon">resume</a>
355356
</li>
356357
</ul>

0 commit comments

Comments
 (0)