assert.js 625 B

123456789101112
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. /**
  6. * Throws an error with the provided message if the provided value does not evaluate to a true Javascript value.
  7. */
  8. export function ok(value, message) {
  9. if (!value) {
  10. throw new Error(message ? `Assertion failed (${message})` : 'Assertion Failed');
  11. }
  12. }