init datamate

This commit is contained in:
Dallas98
2025-10-21 23:00:48 +08:00
commit 1c97afed7d
692 changed files with 135442 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
function log(message, type = "log", provided = 'console') {
const providedFn = globalThis[provided] || console;
if (providedFn && typeof providedFn[type] === 'function') {
const invokeMethod = providedFn[type ?? 'log'];
invokeMethod.call(providedFn, message);
}
}
function addMockPrefix(urlPrefix, api) {
const newMockApi = {};
Object.keys(api).map(apiKey=>{
newMockApi[apiKey] = urlPrefix + api[apiKey];
});
return new Proxy(newMockApi, {
get(target, prop) {
if (prop in target) {
return target[prop];
} else {
throw new Error(`API ${String(prop)} is not defined.`);
}
}
})
}
module.exports = {
log,
addMockPrefix,
};