@socketsecurity/lib
Version:
Core utilities and infrastructure for Socket.dev security tools
71 lines (70 loc) • 1.91 kB
JavaScript
;
/* Socket Lib - Built with esbuild */
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);
var functions_exports = {};
__export(functions_exports, {
noop: () => noop,
once: () => once,
silentWrapAsync: () => silentWrapAsync,
trampoline: () => trampoline
});
module.exports = __toCommonJS(functions_exports);
// @__NO_SIDE_EFFECTS__
function noop() {
}
// @__NO_SIDE_EFFECTS__
function once(fn) {
let called = false;
let result;
return function(...args) {
if (!called) {
called = true;
result = fn.apply(this, args);
}
return result;
};
}
// @__NO_SIDE_EFFECTS__
function silentWrapAsync(fn) {
return async (...args) => {
try {
const result = await fn(...args);
return result === null ? void 0 : result;
} catch {
}
return void 0;
};
}
// @__NO_SIDE_EFFECTS__
function trampoline(fn) {
return function(...args) {
let result = fn.apply(this, args);
while (typeof result === "function") {
result = result();
}
return result;
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
noop,
once,
silentWrapAsync,
trampoline
});