* 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)
| 225 | * throwing if not, indicating the %%className%% if provided. |
| 226 | */ |
| 227 | function 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 | } |
| 242 | exports.assertPrivate = assertPrivate; |
| 243 | //# sourceMappingURL=errors.js.map |