1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const symbols_1 = require("./symbols");
|
4 | function isTransferable(thing) {
|
5 | if (!thing || typeof thing !== "object")
|
6 | return false;
|
7 |
|
8 | return true;
|
9 | }
|
10 | function isTransferDescriptor(thing) {
|
11 | return thing && typeof thing === "object" && thing[symbols_1.$transferable];
|
12 | }
|
13 | exports.isTransferDescriptor = isTransferDescriptor;
|
14 | function Transfer(payload, transferables) {
|
15 | if (!transferables) {
|
16 | if (!isTransferable(payload))
|
17 | throw Error();
|
18 | transferables = [payload];
|
19 | }
|
20 | return {
|
21 | [symbols_1.$transferable]: true,
|
22 | send: payload,
|
23 | transferables
|
24 | };
|
25 | }
|
26 | exports.Transfer = Transfer;
|