feat: new RPC

This commit is contained in:
Elysia
2024-01-31 20:54:42 +07:00
parent 585b71a1af
commit 987aa3a1fb
8 changed files with 870 additions and 968 deletions

View File

@@ -795,6 +795,19 @@ class Util extends null {
.catch(reject);
});
}
/**
* Lazily evaluates a callback function (yea it's v14 :yay:)
* @param {Function} cb The callback to lazily evaluate
* @returns {Function}
* @example
* const User = lazy(() => require('./User'));
* const user = new (User())(client, data);
*/
static lazy(cb) {
let defaultValue;
return () => (defaultValue ??= cb());
}
}
module.exports = Util;