assert.js 306 B

123456789101112131415161718192021
  1. 'use strict';
  2. const AssertError = require('./error');
  3. const internals = {};
  4. module.exports = function (condition, ...args) {
  5. if (condition) {
  6. return;
  7. }
  8. if (args.length === 1 &&
  9. args[0] instanceof Error) {
  10. throw args[0];
  11. }
  12. throw new AssertError(args);
  13. };