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