UNPKG

824 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const symbols_1 = require("./symbols");
4function isTransferable(thing) {
5 if (!thing || typeof thing !== "object")
6 return false;
7 // Don't check too thoroughly, since the list of transferable things in JS might grow over time
8 return true;
9}
10function isTransferDescriptor(thing) {
11 return thing && typeof thing === "object" && thing[symbols_1.$transferable];
12}
13exports.isTransferDescriptor = isTransferDescriptor;
14function 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}
26exports.Transfer = Transfer;