Skip to content

Commit f759072

Browse files
committed
Updated simultaneity; using const in tests
1 parent 0f2ecb7 commit f759072

Some content is hidden

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

81 files changed

+577
-527
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
node_modules
2-
type-value-out
3-
type-out
4-
value-out
52
**/*-noutil.js
63
client-side/upload-download.js

compile.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,43 @@ uploadDownloadB.add(__dirname + '/client-side/upload-download.js')
1616
const s = new Simultaneity
1717
//Replace require('util'), which is only used for util.inspect(), to minimize file size
1818
for (const utilFile of ['/lib/assert', '/structure-types', '/read']) {
19-
s.addTask(() => {
19+
s.addTask(s => {
2020
fs.createReadStream(__dirname + utilFile + '.js')
2121
.pipe(new ReplaceStream("require('util')", "require('/lib/util-inspect.js')"))
2222
.pipe(fs.createWriteStream(__dirname + utilFile + '-noutil.js')).on('finish', () => {
2323
s.taskFinished()
2424
})
2525
})
2626
}
27-
s.addTask(() => {
27+
s.addTask(s => {
2828
//Load the upload and download code and append them to each other to make a combined include file
2929
//These files are not too big, so it is not terrible to load them into memory
3030
let uploadCode, downloadCode
31-
const loadS = new Simultaneity
32-
loadS.addTask(() => {
33-
fs.readFile(__dirname + '/client-side/upload.js', (err, data) => {
34-
if (err) throw err
35-
uploadCode = data
36-
loadS.taskFinished()
37-
})
38-
})
39-
loadS.addTask(() => {
40-
fs.readFile(__dirname + '/client-side/download.js', (err, data) => {
41-
if (err) throw err
42-
downloadCode = data
43-
loadS.taskFinished()
31+
new Simultaneity()
32+
.addTask(s => {
33+
fs.readFile(__dirname + '/client-side/upload.js', (err, data) => {
34+
if (err) throw err
35+
uploadCode = data
36+
s.taskFinished()
37+
})
4438
})
45-
})
46-
loadS.callback(() => {
47-
fs.writeFile(
48-
__dirname + '/client-side/upload-download.js',
49-
Buffer.concat([uploadCode, Buffer.from(';'), downloadCode]),
50-
err => {
39+
.addTask(s => {
40+
fs.readFile(__dirname + '/client-side/download.js', (err, data) => {
5141
if (err) throw err
42+
downloadCode = data
5243
s.taskFinished()
53-
}
54-
)
55-
})
44+
})
45+
})
46+
.callback(() => {
47+
fs.writeFile(
48+
__dirname + '/client-side/upload-download.js',
49+
Buffer.concat([uploadCode, Buffer.from(';'), downloadCode]),
50+
err => {
51+
if (err) throw err
52+
s.taskFinished()
53+
}
54+
)
55+
})
5656
})
5757
console.log('Compiling: Replacing large dependencies')
5858
const downloadFiles = [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"coveralls": "2.11.x",
1717
"google-closure-compiler-js": "20161201.0.0",
1818
"nyc": "10.0.x",
19-
"simultaneity": "1.0.x"
19+
"simultaneity": "1.1.x"
2020
},
2121
"directories": {
2222
"test": "test"
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
/*eslint-disable no-undef*/
2-
let s = new Simultaneity
3-
let inBuffer = new ArrayBuffer(0)
4-
let bs = new BufferStream(inBuffer)
5-
let outChunks = []
6-
s.addTask(() => {
7-
bs.on('data', chunk => outChunks.push(chunk)).on('end', () => {
8-
assert.equal(Buffer.concat(outChunks), Buffer.from(inBuffer))
9-
s.taskFinished()
2+
const wait = setInterval(() => {}, 10)
3+
new Simultaneity()
4+
.addTask(s => {
5+
const inBuffer = new ArrayBuffer(0)
6+
const bs = new BufferStream(inBuffer)
7+
const outChunks = []
8+
bs.on('data', chunk => outChunks.push(chunk)).on('end', () => {
9+
assert.equal(Buffer.concat(outChunks), Buffer.from(inBuffer))
10+
s.taskFinished()
11+
})
1012
})
11-
})
12-
let inBuffer2 = Buffer.allocUnsafe(100000).buffer
13-
let bs2 = new BufferStream(inBuffer2)
14-
let outChunks2 = []
15-
s.addTask(() => {
16-
bs2.on('data', chunk => outChunks2.push(chunk)).on('end', () => {
17-
assert.equal(Buffer.concat(outChunks2), Buffer.from(inBuffer2))
18-
s.taskFinished()
13+
.addTask(s => {
14+
const inBuffer2 = Buffer.allocUnsafe(100000).buffer
15+
const bs2 = new BufferStream(inBuffer2)
16+
const outChunks2 = []
17+
bs2.on('data', chunk => outChunks2.push(chunk)).on('end', () => {
18+
assert.equal(Buffer.concat(outChunks2), Buffer.from(inBuffer2))
19+
s.taskFinished()
20+
})
1921
})
20-
})
21-
let wait = setInterval(() => {}, 10)
22-
s.callback(() => clearInterval(wait))
22+
.callback(() => clearInterval(wait))

test/errors/assert.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ assert.throws(
3939
() => assert.equal(bufferFrom([1, 2, 5]), bufferFrom([1, 2, 3])),
4040
'Expected ArrayBuffer { byteLength: 3 } but got ArrayBuffer { byteLength: 3 }'
4141
)
42-
let a = {func() {}},
42+
const a = {func() {}},
4343
b = {func() {}}
4444
assert.throws(
4545
() => assert.assert(a.func === b.func, 'Unequal'),
@@ -59,8 +59,8 @@ assert.throws(
5959
() => assert.message(null, 'Error occurred'),
6060
'Message "No error thrown" does not start with "Error occurred"'
6161
)
62-
for (let Type of [Array, Map, Set, ArrayBuffer]) {
63-
let value = new Type
62+
for (const type of [Array, Map, Set, ArrayBuffer]) {
63+
const value = new type //eslint-disable-line new-cap
6464
assert.throws(
6565
() => assert.equal(undefined, value),
6666
'Expected ' + require('util').inspect(value) + ' but got undefined'

test/errors/io.js

Lines changed: 78 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,96 @@
11
/*eslint-disable no-undef*/
2-
let s = new Simultaneity
3-
s.addTask(() => {
4-
io.readTypeAndValue(new BufferStream(bufferFrom([t.ArrayType._value])), (err, type, value) => {
5-
assert.message(err, 'Buffer is not long enough')
6-
assert.equal(type, null)
7-
assert.equal(value, null)
8-
s.taskFinished()
2+
const wait = setInterval(() => {}, 10)
3+
const s = new Simultaneity()
4+
.addTask(s => {
5+
io.readTypeAndValue(new BufferStream(bufferFrom([t.ArrayType._value])), (err, type, value) => {
6+
assert.message(err, 'Buffer is not long enough')
7+
assert.equal(type, null)
8+
assert.equal(value, null)
9+
s.taskFinished()
10+
})
911
})
10-
})
11-
s.addTask(() => {
12-
let type = new t.ArrayType(new t.UnsignedShortType)
13-
let typeValueBuffer = concat([
14-
type.toBuffer(),
15-
bufferFrom([0, 0, 0, 1])
16-
])
17-
io.readTypeAndValue(new BufferStream(typeValueBuffer), (err, type, value) => {
18-
assert.message(err, 'Buffer is not long enough')
19-
assert.equal(type, null)
20-
assert.equal(value, null)
21-
s.taskFinished()
12+
.addTask(s => {
13+
const type = new t.ArrayType(new t.UnsignedShortType)
14+
const typeValueBuffer = concat([
15+
type.toBuffer(),
16+
bufferFrom([0, 0, 0, 1])
17+
])
18+
io.readTypeAndValue(new BufferStream(typeValueBuffer), (err, type, value) => {
19+
assert.message(err, 'Buffer is not long enough')
20+
assert.equal(type, null)
21+
assert.equal(value, null)
22+
s.taskFinished()
23+
})
2224
})
23-
})
24-
s.addTask(() => {
25-
let errorStream = fs.createReadStream(__dirname + '/asdfasdf')
26-
io.readType(errorStream, (err, type) => {
27-
assert.message(err, 'ENOENT')
28-
assert.equal(type, null)
29-
s.taskFinished()
25+
.addTask(s => {
26+
const errorStream = fs.createReadStream(__dirname + '/asdfasdf')
27+
io.readType(errorStream, (err, type) => {
28+
assert.message(err, 'ENOENT')
29+
assert.equal(type, null)
30+
s.taskFinished()
31+
})
3032
})
31-
})
32-
s.addTask(() => {
33-
let type = new t.StringType
34-
let errorStream = fs.createReadStream(__dirname + '/asdfasdf')
35-
io.readValue({type, inStream: errorStream}, (err, value) => {
36-
assert.message(err, 'ENOENT')
37-
assert.equal(value, null)
38-
s.taskFinished()
33+
.addTask(s => {
34+
const type = new t.StringType
35+
const errorStream = fs.createReadStream(__dirname + '/asdfasdf')
36+
io.readValue({type, inStream: errorStream}, (err, value) => {
37+
assert.message(err, 'ENOENT')
38+
assert.equal(value, null)
39+
s.taskFinished()
40+
})
3941
})
40-
})
41-
s.addTask(() => {
42-
let errorStream = fs.createReadStream(__dirname + '/asdfasdf')
43-
io.readTypeAndValue(errorStream, (err, type, value) => {
44-
assert.message(err, 'ENOENT')
45-
assert.equal(type, null)
46-
assert.equal(value, null)
47-
s.taskFinished()
42+
.addTask(s => {
43+
const errorStream = fs.createReadStream(__dirname + '/asdfasdf')
44+
io.readTypeAndValue(errorStream, (err, type, value) => {
45+
assert.message(err, 'ENOENT')
46+
assert.equal(type, null)
47+
assert.equal(value, null)
48+
s.taskFinished()
49+
})
4850
})
49-
})
50-
let intsType = new t.ArrayType(
51+
const intsType = new t.ArrayType(
5152
new t.OptionalType(
5253
new t.UnsignedIntType
5354
)
5455
)
55-
s.addTask(() => {
56-
let errorStream = fs.createWriteStream(__dirname + '/asdf/asdf')
56+
s.addTask(s => {
57+
const errorStream = fs.createWriteStream(__dirname + '/asdf/asdf')
5758
assert.equal(errorStream.writable, true)
58-
let type = intsType
59-
io.writeType({type, outStream: errorStream}, err => {
59+
io.writeType({
60+
type: intsType,
61+
outStream: errorStream
62+
}, err => {
6063
assert.message(err, 'ENOENT')
6164
assert.equal(errorStream.writable, false)
6265
s.taskFinished()
6366
})
6467
})
65-
let intsValue = [null, 10, 30, 20, null, 55]
66-
s.addTask(() => {
67-
let errorStream = fs.createWriteStream(__dirname + '/asdf/asdf')
68-
assert.equal(errorStream.writable, true)
69-
let type = intsType
70-
let value = intsValue
71-
io.writeValue({type, value, outStream: errorStream}, err => {
72-
assert.message(err, 'ENOENT')
73-
assert.equal(errorStream.writable, false)
74-
s.taskFinished()
68+
const intsValue = [null, 10, 30, 20, null, 55]
69+
s
70+
.addTask(s => {
71+
const errorStream = fs.createWriteStream(__dirname + '/asdf/asdf')
72+
assert.equal(errorStream.writable, true)
73+
io.writeValue({
74+
type: intsType,
75+
value: intsValue,
76+
outStream: errorStream
77+
}, err => {
78+
assert.message(err, 'ENOENT')
79+
assert.equal(errorStream.writable, false)
80+
s.taskFinished()
81+
})
7582
})
76-
})
77-
s.addTask(() => {
78-
let errorStream = fs.createWriteStream(__dirname + '/asdf/asdf')
79-
assert.equal(errorStream.writable, true)
80-
let type = intsType
81-
let value = intsValue
82-
io.writeTypeAndValue({type, value, outStream: errorStream}, err => {
83-
assert.message(err, 'ENOENT')
84-
assert.equal(errorStream.writable, false)
85-
s.taskFinished()
83+
.addTask(s => {
84+
const errorStream = fs.createWriteStream(__dirname + '/asdf/asdf')
85+
assert.equal(errorStream.writable, true)
86+
io.writeTypeAndValue({
87+
type: intsType,
88+
value: intsValue,
89+
outStream: errorStream
90+
}, err => {
91+
assert.message(err, 'ENOENT')
92+
assert.equal(errorStream.writable, false)
93+
s.taskFinished()
94+
})
8695
})
87-
})
88-
let wait = setInterval(() => {}, 10)
89-
s.callback(() => clearInterval(wait))
96+
.callback(() => clearInterval(wait))

test/errors/type.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ assert.throws(
33
() => t.Type._value,
44
'Generic Type has no value byte'
55
)
6-
let type = new t.Type
6+
const type = new t.Type
77
assert.throws(
88
() => type.valueBuffer(23),
99
'Generic Type has no value representation'

test/growable-buffer/constructor.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*eslint-disable no-undef*/
2-
let a = new GrowableBuffer
3-
assert.equal(a.buffer.byteLength, 10)
4-
a = new GrowableBuffer(100)
5-
assert.equal(a.buffer.byteLength, 100)
6-
for (let [invalidSize, message] of [
2+
const gb = new GrowableBuffer
3+
assert.equal(gb.buffer.byteLength, 10)
4+
const gb2 = new GrowableBuffer(100)
5+
assert.equal(gb2.buffer.byteLength, 100)
6+
for (const [invalidSize, message] of [
77
[-1, '-1 is not a valid buffer length'],
88
[Number.MAX_SAFE_INTEGER + 1, '9007199254740992 is not a valid buffer length'],
99
[null, 'null is not a valid buffer length'],

0 commit comments

Comments
 (0)