MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / assertPrivate

Function assertPrivate

lib.commonjs/utils/errors.js:227–241  ·  view source on GitHub ↗

* Many classes use file-scoped values to guard the constructor, * making it effectively private. This facilitates that pattern * by ensuring the %%givenGaurd%% matches the file-scoped %%guard%%, * throwing if not, indicating the %%className%% if provided.

(givenGuard, guard, className)

Source from the content-addressed store, hash-verified

225 * throwing if not, indicating the %%className%% if provided.
226 */
227function assertPrivate(givenGuard, guard, className) {
228 if (className == null) {
229 className = "";
230 }
231 if (givenGuard !== guard) {
232 let method = className, operation = "new";
233 if (className) {
234 method += ".";
235 operation += " " + className;
236 }
237 assert(false, `private constructor; use ${method}from* methods`, "UNSUPPORTED_OPERATION", {
238 operation
239 });
240 }
241}
242exports.assertPrivate = assertPrivate;
243//# sourceMappingURL=errors.js.map

Callers

nothing calls this directly

Calls 1

assertFunction · 0.70

Tested by

no test coverage detected