Skip to content

Commit

Permalink
Version bump to 2.14; created docs
Browse files Browse the repository at this point in the history
  • Loading branch information
calebsander committed Sep 5, 2016
1 parent 6d89037 commit 8586a04
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 74 deletions.
4 changes: 2 additions & 2 deletions docs/BigIntType.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h4 class="name" id="BigIntType"><span class="type-signature"></span>new BigIntT

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line331">line 331</a>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line334">line 334</a>
</li></ul></dd>


Expand Down Expand Up @@ -1097,7 +1097,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line341">line 341</a>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line344">line 344</a>
</li></ul></dd>


Expand Down
4 changes: 2 additions & 2 deletions docs/LongType.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h4 class="name" id="LongType"><span class="type-signature"></span>new LongType<

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line301">line 301</a>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line313">line 313</a>
</li></ul></dd>


Expand Down Expand Up @@ -1095,7 +1095,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line311">line 311</a>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line323">line 323</a>
</li></ul></dd>


Expand Down
4 changes: 2 additions & 2 deletions docs/UnsignedByteType.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h4 class="name" id="UnsignedByteType"><span class="type-signature"></span>new U

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line376">line 376</a>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line379">line 379</a>
</li></ul></dd>


Expand Down Expand Up @@ -1098,7 +1098,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line386">line 386</a>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line389">line 389</a>
</li></ul></dd>


Expand Down
4 changes: 2 additions & 2 deletions docs/UnsignedIntType.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h4 class="name" id="UnsignedIntType"><span class="type-signature"></span>new Un

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line428">line 428</a>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line431">line 431</a>
</li></ul></dd>


Expand Down Expand Up @@ -1098,7 +1098,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line438">line 438</a>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line441">line 441</a>
</li></ul></dd>


Expand Down
4 changes: 2 additions & 2 deletions docs/UnsignedLongType.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h4 class="name" id="UnsignedLongType"><span class="type-signature"></span>new U

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line467">line 467</a>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line458">line 458</a>
</li></ul></dd>


Expand Down Expand Up @@ -1095,7 +1095,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line477">line 477</a>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line468">line 468</a>
</li></ul></dd>


Expand Down
4 changes: 2 additions & 2 deletions docs/UnsignedShortType.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h4 class="name" id="UnsignedShortType"><span class="type-signature"></span>new

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line402">line 402</a>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line405">line 405</a>
</li></ul></dd>


Expand Down Expand Up @@ -1098,7 +1098,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line412">line 412</a>
<a href="structure-types.js.html">structure-types.js</a>, <a href="structure-types.js.html#line415">line 415</a>
</li></ul></dd>


Expand Down
22 changes: 11 additions & 11 deletions docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ <h6>Properties</h6>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line209">line 209</a>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line212">line 212</a>
</li></ul></dd>


Expand Down Expand Up @@ -701,7 +701,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line109">line 109</a>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line112">line 112</a>
</li></ul></dd>


Expand Down Expand Up @@ -858,7 +858,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line179">line 179</a>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line182">line 182</a>
</li></ul></dd>


Expand Down Expand Up @@ -1088,7 +1088,7 @@ <h6>Properties</h6>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line142">line 142</a>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line145">line 145</a>
</li></ul></dd>


Expand Down Expand Up @@ -1591,7 +1591,7 @@ <h6>Properties</h6>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line25">line 25</a>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line28">line 28</a>
</li></ul></dd>


Expand Down Expand Up @@ -1887,7 +1887,7 @@ <h6>Properties</h6>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line73">line 73</a>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line76">line 76</a>
</li></ul></dd>


Expand Down Expand Up @@ -2181,7 +2181,7 @@ <h6>Properties</h6>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line48">line 48</a>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line51">line 51</a>
</li></ul></dd>


Expand Down Expand Up @@ -2343,7 +2343,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line20">line 20</a>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line23">line 23</a>
</li></ul></dd>


Expand Down Expand Up @@ -2530,7 +2530,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line171">line 171</a>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line174">line 174</a>
</li></ul></dd>


Expand Down Expand Up @@ -2691,7 +2691,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line102">line 102</a>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line105">line 105</a>
</li></ul></dd>


Expand Down Expand Up @@ -2852,7 +2852,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line135">line 135</a>
<a href="io.js.html">io.js</a>, <a href="io.js.html#line138">line 138</a>
</li></ul></dd>


Expand Down
38 changes: 24 additions & 14 deletions docs/io.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ <h1 class="page-title">Source: io.js</h1>
//This file contains functions for performing I/O;
//specifically, reads and writes of types and values and HTTP responses

const accepts = require('accepts')
const assert = require(__dirname + '/lib/assert.js')
const BufferStream = require(__dirname + '/lib/buffer-stream.js')
const GrowableBuffer = require(__dirname + '/lib/growable-buffer.js')
const http = require('http')
const r = require(__dirname + '/read.js')
const stream = require('stream')
const t = require(__dirname + '/structure-types.js')
Expand All @@ -43,6 +45,7 @@ <h1 class="page-title">Source: io.js</h1>
function toArrayBuffer(buffer) {
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength)
}
const WRITABLE_STREAMS = [stream.Writable, stream.Duplex, http.ServerResponse]

const io = module.exports = {
/**
Expand All @@ -64,7 +67,7 @@ <h1 class="page-title">Source: io.js</h1>
*/
writeType({type, outStream}, callback) {
assert.instanceOf(type, t.Type)
assert.instanceOf(outStream, [stream.Writable, stream.Duplex])
assert.instanceOf(outStream, WRITABLE_STREAMS)
if (callback === undefined) callback = () => {}
assert.instanceOf(callback, Function)
const typeStream = new BufferStream(type.toBuffer())
Expand All @@ -88,7 +91,7 @@ <h1 class="page-title">Source: io.js</h1>
*/
writeValue({type, value, outStream}, callback) {
assert.instanceOf(type, t.Type)
assert.instanceOf(outStream, [stream.Writable, stream.Duplex])
assert.instanceOf(outStream, WRITABLE_STREAMS)
if (callback === undefined) callback = () => {}
assert.instanceOf(callback, Function)
const valueBuffer = new GrowableBuffer
Expand All @@ -115,7 +118,7 @@ <h1 class="page-title">Source: io.js</h1>
*/
writeTypeAndValue({type, value, outStream}, callback) {
assert.instanceOf(type, t.Type)
assert.instanceOf(outStream, [stream.Writable, stream.Duplex])
assert.instanceOf(outStream, WRITABLE_STREAMS)
if (callback === undefined) callback = () => {}
assert.instanceOf(callback, Function)
const typeStream = new BufferStream(type.toBuffer())
Expand Down Expand Up @@ -250,25 +253,32 @@ <h1 class="page-title">Source: io.js</h1>
* @param {errCallback=} callback
*/
httpRespond({req, res, type, value}, callback) {
function writeEndCallback(acceptsGzip) {
return err => {
if (err) callback(err)
if (!acceptsGzip) callback(null)
}
}
assert.instanceOf(type, t.Type)
if (callback === undefined) callback = () => {}
assert.instanceOf(callback, Function)
assert.instanceOf(req, http.IncomingMessage)
assert.instanceOf(res, http.ServerResponse)
try {
res.setHeader('Content-Type', 'application/octet-stream')
res.setHeader('Content-Encoding', 'gzip')
res.setHeader('sig', type.getSignature())
const outStream = zlib.createGzip() //pipe into a zip stream to decrease size of response
if (req.headers.sig &amp;&amp; req.headers.sig === type.getSignature()) { //if client already has type, only value needs to be sent
io.writeValue({type, value, outStream}, err => {
if (err) callback(err)
})
const acceptsGzip = accepts(req).encoding(['gzip'])
let outStream
if (acceptsGzip) {
res.setHeader('Content-Encoding', 'gzip')
outStream = zlib.createGzip() //pipe into a zip stream to decrease size of response
}
else { //otherwise, type and value need to be sent
io.writeTypeAndValue({type, value, outStream}, err => {
if (err) callback(err)
})
else outStream = res
if (req.headers.sig &amp;&amp; req.headers.sig === type.getSignature()) { //if client already has type, only value needs to be sent
io.writeValue({type, value, outStream}, writeEndCallback(acceptsGzip))
}
outStream.pipe(res).on('finish', () => callback(null))
else io.writeTypeAndValue({type, value, outStream}, writeEndCallback(acceptsGzip)) //otherwise, type and value need to be sent
if (acceptsGzip) outStream.pipe(res).on('finish', () => callback(null)) //don't pipe until writing begins
}
catch (err) { callback(err) }
}
Expand Down
6 changes: 3 additions & 3 deletions docs/r.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ <h2>r</h2>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="read.js.html">read.js</a>, <a href="read.js.html#line483">line 483</a>
<a href="read.js.html">read.js</a>, <a href="read.js.html#line484">line 484</a>
</li></ul></dd>


Expand Down Expand Up @@ -262,7 +262,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="read.js.html">read.js</a>, <a href="read.js.html#line496">line 496</a>
<a href="read.js.html">read.js</a>, <a href="read.js.html#line497">line 497</a>
</li></ul></dd>


Expand Down Expand Up @@ -555,7 +555,7 @@ <h6>Properties</h6>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="read.js.html">read.js</a>, <a href="read.js.html#line509">line 509</a>
<a href="read.js.html">read.js</a>, <a href="read.js.html#line510">line 510</a>
</li></ul></dd>


Expand Down
13 changes: 7 additions & 6 deletions docs/read.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,15 @@ <h1 class="page-title">Source: read.js</h1>
value = dataView.getInt32(offset)
break
}
case t.LongType: {
case t.LongType:
case t.DateType: {
length = 8
assert.assert(buffer.byteLength >= offset + length, NOT_LONG_ENOUGH)
const dataView = new DataView(buffer)
const upper = dataView.getInt32(offset)
const lower = dataView.getUint32(offset + 4)
value = strint.add(strint.mul(String(upper), strint.LONG_UPPER_SHIFT), String(lower))
if (type.constructor === t.DateType) value = new Date(Number(value))
break
}
case t.BigIntType: {
Expand Down Expand Up @@ -166,15 +168,13 @@ <h1 class="page-title">Source: read.js</h1>
value = new DataView(buffer).getUint32(offset)
break
}
case t.UnsignedLongType:
case t.DateType: {
case t.UnsignedLongType: {
length = 8
assert.assert(buffer.byteLength >= offset + length, NOT_LONG_ENOUGH)
const dataView = new DataView(buffer)
const upper = dataView.getUint32(offset)
const lower = dataView.getUint32(offset + 4)
value = strint.add(strint.mul(String(upper), strint.LONG_UPPER_SHIFT), String(lower))
if (type.constructor === t.DateType) value = new Date(Number(value))
break
}
case t.BigUnsignedIntType: {
Expand All @@ -195,8 +195,9 @@ <h1 class="page-title">Source: read.js</h1>
length = 3
assert.assert(buffer.byteLength >= offset + length, NOT_LONG_ENOUGH)
const dataView = new DataView(buffer)
const day = (dataView.getUint16(offset) &lt;&lt; 8) | dataView.getUint8(offset + 2)
value = new Date(day * t.MILLIS_PER_DAY + new Date().getTimezoneOffset() * t.MILLIS_PER_MINUTE)
const day = (dataView.getInt16(offset) &lt;&lt; 8) | dataView.getUint8(offset + 2)
const utcDate = day * t.MILLIS_PER_DAY
value = new Date(utcDate + new Date(utcDate).getTimezoneOffset() * t.MILLIS_PER_MINUTE)
break
}
case t.TimeType: {
Expand Down
Loading

0 comments on commit 8586a04

Please sign in to comment.