@msquared/pixel-streaming-client
Version:
Browser client for viewing pixel-streamed content from MSquared events
66 lines (64 loc) • 1.78 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/errors.ts
var errors_exports = {};
__export(errors_exports, {
default: () => errors_default
});
module.exports = __toCommonJS(errors_exports);
function is(value, target = Error) {
if (typeof target === "function") {
return value instanceof target;
}
if (value instanceof Error) {
return value === target;
}
return false;
}
function wrap(cause) {
if (cause instanceof Error) {
return cause;
}
return new Error("unknown error", { cause });
}
function catch_(fn, ...errors) {
try {
return fn();
} catch (e) {
if (errors.length === 0) {
return wrap(e);
}
for (const error of errors) {
if (is(e, error)) {
return e;
}
}
throw e;
}
}
function as(value, target = Error) {
if (is(value, target)) {
return value;
}
if (value instanceof Error && value.cause !== void 0) {
return as(value.cause, target);
}
return void 0;
}
var errors_default = { is, wrap, catch: catch_, as };