-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b9ed7c
commit 4cc1c81
Showing
29 changed files
with
338 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { int32_arrays } from "../data.js"; | ||
import { expect } from "https://esm.sh/v126/[email protected]/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs"; | ||
|
||
/** @param {unknown[]} received */ | ||
export const check = (received) => { | ||
for (const [i, typed_array] of int32_arrays.entries()) { | ||
expect(received[i]).to.be.an.instanceof(ArrayBuffer); | ||
expect(new Int32Array(received[i])).to.deep.equal(typed_array); | ||
} | ||
}; | ||
/** | ||
* @param {import("../peerjs").DataConnection} dataConnection | ||
*/ | ||
export const send = (dataConnection) => { | ||
for (const typed_array of int32_arrays) { | ||
dataConnection.send(typed_array); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { typed_array_view } from "../data.js"; | ||
import { expect } from "https://esm.sh/v126/[email protected]/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs"; | ||
|
||
/** @param {unknown[]} received */ | ||
export const check = (received) => { | ||
const received_typed_array_view = received[0]; | ||
expect(received_typed_array_view).to.be.instanceOf(ArrayBuffer); | ||
expect(new Uint8Array(received_typed_array_view)).to.deep.equal( | ||
typed_array_view, | ||
); | ||
}; | ||
/** | ||
* @param {import("../peerjs").DataConnection} dataConnection | ||
*/ | ||
export const send = (dataConnection) => { | ||
dataConnection.send(typed_array_view); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { uint8_arrays } from "../data.js"; | ||
import { expect } from "https://esm.sh/v126/[email protected]/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs"; | ||
|
||
/** @param {unknown[]} received */ | ||
export const check = (received) => { | ||
for (const [i, typed_array] of uint8_arrays.entries()) { | ||
expect(received[i]).to.be.an.instanceof(ArrayBuffer); | ||
expect(new Uint8Array(received[i])).to.deep.equal(typed_array); | ||
} | ||
}; | ||
/** | ||
* @param {import("../peerjs").DataConnection} dataConnection | ||
*/ | ||
export const send = (dataConnection) => { | ||
for (const typed_array of uint8_arrays) { | ||
dataConnection.send(typed_array); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,18 @@ | ||
import { typed_arrays, typed_array_view, array_buffers } from "../data.js"; | ||
import { array_buffers } from "../data.js"; | ||
import { expect } from "https://esm.sh/v126/[email protected]/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs"; | ||
|
||
/** @param {unknown[]} received */ | ||
window.check = (received) => { | ||
for (const [i, typed_array] of typed_arrays.entries()) { | ||
expect(received[i]).to.be.an.instanceof(ArrayBuffer); | ||
expect(received[i]).to.deep.equal(typed_array.buffer); | ||
} | ||
export const check = (received) => { | ||
for (const [i, array_buffer] of array_buffers.entries()) { | ||
expect(received[typed_arrays.length + i]).to.be.an.instanceof(ArrayBuffer); | ||
expect(received[typed_arrays.length + i]).to.deep.equal(array_buffer); | ||
} | ||
|
||
const received_typed_array_view = | ||
received[typed_arrays.length + array_buffers.length]; | ||
expect(new Uint8Array(received_typed_array_view)).to.deep.equal( | ||
typed_array_view, | ||
); | ||
for (const [i, v] of new Uint8Array(received_typed_array_view).entries()) { | ||
expect(v).to.deep.equal(typed_array_view[i]); | ||
expect(received[i]).to.be.an.instanceof(ArrayBuffer); | ||
expect(received[i]).to.deep.equal(array_buffer); | ||
} | ||
}; | ||
/** | ||
* @param {import("../peerjs").DataConnection} dataConnection | ||
*/ | ||
window.send = (dataConnection) => { | ||
for (const typed_array of typed_arrays) { | ||
dataConnection.send(typed_array); | ||
} | ||
export const send = (dataConnection) => { | ||
for (const array_buffer of array_buffers) { | ||
dataConnection.send(array_buffer); | ||
} | ||
dataConnection.send(typed_array_view); | ||
}; | ||
|
||
window["connect-btn"].disabled = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,14 @@ import { commit_data } from "../data.js"; | |
import { expect } from "https://esm.sh/v126/[email protected]/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs"; | ||
|
||
/** @param {unknown[]} received */ | ||
window.check = (received) => { | ||
export const check = (received) => { | ||
expect(received[1]).to.be.an("array").with.lengthOf(commit_data.length); | ||
expect(received).to.deep.equal([[], commit_data]); | ||
}; | ||
/** | ||
* @param {import("../peerjs").DataConnection} dataConnection | ||
*/ | ||
window.send = (dataConnection) => { | ||
export const send = (dataConnection) => { | ||
dataConnection.send([]); | ||
dataConnection.send(commit_data); | ||
}; | ||
window["connect-btn"].disabled = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,13 @@ import { commit_data } from "../data.js"; | |
import { expect } from "https://esm.sh/v126/[email protected]/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs"; | ||
|
||
/** @param {unknown[]} received */ | ||
window.check = (received) => { | ||
export const check = (received) => { | ||
expect(received).to.deep.equal([[], commit_data.slice(0, 2)]); | ||
}; | ||
/** | ||
* @param {import("../peerjs").DataConnection} dataConnection | ||
*/ | ||
window.send = (dataConnection) => { | ||
export const send = (dataConnection) => { | ||
dataConnection.send([]); | ||
dataConnection.send(commit_data.slice(0, 2)); | ||
}; | ||
window["connect-btn"].disabled = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { dates } from "../data.js"; | ||
import { expect } from "https://esm.sh/v126/[email protected]/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs"; | ||
|
||
/** @param {unknown[]} received */ | ||
export const check = (received) => { | ||
console.log(dates.map((date) => date.toString())); | ||
expect(received).to.deep.equal(dates.map((date) => date.toJSON())); | ||
}; | ||
/** | ||
* @param {import("../peerjs").DataConnection} dataConnection | ||
*/ | ||
export const send = (dataConnection) => { | ||
for (const date of dates) { | ||
dataConnection.send(date); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { dates } from "../data.js"; | ||
import { expect } from "https://esm.sh/v126/[email protected]/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs"; | ||
|
||
/** @param {unknown[]} received */ | ||
export const check = (received) => { | ||
console.log(dates.map((date) => date.toString())); | ||
expect(received).to.deep.equal(dates.map((date) => date.toString())); | ||
}; | ||
/** | ||
* @param {import("../peerjs").DataConnection} dataConnection | ||
*/ | ||
export const send = (dataConnection) => { | ||
for (const date of dates) { | ||
dataConnection.send(date); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { long_string } from "../data.js"; | ||
import { expect } from "https://esm.sh/v126/[email protected]/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs"; | ||
|
||
/** @param {unknown[]} received */ | ||
export const check = (received) => { | ||
expect(received).to.deep.equal([long_string]); | ||
}; | ||
/** | ||
* @param {import("../peerjs").DataConnection} dataConnection | ||
*/ | ||
export const send = (dataConnection) => { | ||
dataConnection.send(long_string); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,14 @@ import { numbers } from "../data.js"; | |
import { expect } from "https://esm.sh/v126/[email protected]/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs"; | ||
|
||
/** @param {unknown[]} received */ | ||
window.check = (received) => { | ||
export const check = (received) => { | ||
expect(received).to.deep.equal(numbers); | ||
}; | ||
/** | ||
* @param {import("../peerjs").DataConnection} dataConnection | ||
*/ | ||
window.send = (dataConnection) => { | ||
export const send = (dataConnection) => { | ||
for (const number of numbers) { | ||
dataConnection.send(number); | ||
} | ||
}; | ||
window["connect-btn"].disabled = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,15 @@ import { commit_data } from "../data.js"; | |
import { expect } from "https://esm.sh/v126/[email protected]/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs"; | ||
|
||
/** @param {unknown[]} received */ | ||
window.check = (received) => { | ||
export const check = (received) => { | ||
expect(received).to.be.an("array").with.lengthOf(commit_data.length); | ||
expect(received).to.deep.equal(commit_data); | ||
}; | ||
/** | ||
* @param {import("../peerjs").DataConnection} dataConnection | ||
*/ | ||
window.send = (dataConnection) => { | ||
export const send = (dataConnection) => { | ||
for (const commit of commit_data) { | ||
dataConnection.send(commit); | ||
} | ||
}; | ||
window["connect-btn"].disabled = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,7 @@ <h1>Serialization</h1> | |
<div id="messages"></div> | ||
<div id="result"></div> | ||
<div id="error-message"></div> | ||
<script src="/dist/peerjs.js"></script> | ||
<!--<script src="https://unpkg.com/[email protected]/dist/peerjs.min.js"></script>--> | ||
<script> | ||
import(window.location.search.substring(6)); | ||
</script> | ||
<script src="/dist/peerjs.min.js" type="application/javascript"></script> | ||
<script src="serialization.js" type="module"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.