convex
Version:
Client for the Convex Cloud
59 lines (58 loc) • 2.23 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);
var paths_exports = {};
__export(paths_exports, {
extractReferencePath: () => extractReferencePath,
getFunctionAddress: () => getFunctionAddress,
isFunctionHandle: () => isFunctionHandle,
setReferencePath: () => setReferencePath,
toReferencePath: () => toReferencePath
});
module.exports = __toCommonJS(paths_exports);
var import_functionName = require("../functionName.js");
const toReferencePath = Symbol.for("toReferencePath");
function setReferencePath(obj, value) {
obj[toReferencePath] = value;
}
function extractReferencePath(reference) {
return reference[toReferencePath] ?? null;
}
function isFunctionHandle(s) {
return s.startsWith("function://");
}
function getFunctionAddress(functionReference) {
let functionAddress;
if (typeof functionReference === "string") {
if (isFunctionHandle(functionReference)) {
functionAddress = { functionHandle: functionReference };
} else {
functionAddress = { name: functionReference };
}
} else if (functionReference[import_functionName.functionName]) {
functionAddress = { name: functionReference[import_functionName.functionName] };
} else {
const referencePath = extractReferencePath(functionReference);
if (!referencePath) {
throw new Error(`${functionReference} is not a functionReference`);
}
functionAddress = { reference: referencePath };
}
return functionAddress;
}
//# sourceMappingURL=paths.js.map