xref: /third_party/node/lib/internal/assert.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/lib/internal/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_cilet error;
41cb0ef41Sopenharmony_cifunction lazyError() {
51cb0ef41Sopenharmony_ci  if (!error) {
61cb0ef41Sopenharmony_ci    error = require('internal/errors').codes.ERR_INTERNAL_ASSERTION;
71cb0ef41Sopenharmony_ci  }
81cb0ef41Sopenharmony_ci  return error;
91cb0ef41Sopenharmony_ci}
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cifunction assert(value, message) {
121cb0ef41Sopenharmony_ci  if (!value) {
131cb0ef41Sopenharmony_ci    const ERR_INTERNAL_ASSERTION = lazyError();
141cb0ef41Sopenharmony_ci    throw new ERR_INTERNAL_ASSERTION(message);
151cb0ef41Sopenharmony_ci  }
161cb0ef41Sopenharmony_ci}
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_cifunction fail(message) {
191cb0ef41Sopenharmony_ci  const ERR_INTERNAL_ASSERTION = lazyError();
201cb0ef41Sopenharmony_ci  throw new ERR_INTERNAL_ASSERTION(message);
211cb0ef41Sopenharmony_ci}
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ciassert.fail = fail;
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_cimodule.exports = assert;
26

Indexes created Thu Nov 07 10:32:03 CST 2024