Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@itwin/core-bentley

Package Overview
Dependencies
Maintainers
2
Versions
975
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@itwin/core-bentley - npm Package Compare versions

Comparing version 3.0.0-dev.109 to 3.0.0-dev.112

30

lib/cjs/Assert.d.ts
/** @packageDocumentation
* @module Utils
*/
/**
* Asserts that a condition is `true`, and in development builds throws an error if it is not.
* This is an [assertion function](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions) that alters the
* behavior of the TypeScript compiler.
* @param condition The result of a boolean expression.
* @param msg An optional message to include in the thrown exception. Defaults to "Programmer Error".
* @throws Error containing the specified message if condition is false.
* @note This function should be used to validate conditions that should never realistically occur, or
* which indicate a misuse of the API which should be eliminated during development.
/** Asserts that a condition is `true` and - when enabled - throws an error if it is not.
* Assertions are enabled only if the build configuration defines `process.env.NODE_ENV` as `development` at build time.
*
* Assertions exist solely to assist programmers during development, in the following ways:
* 1 They allow the programmer to declare conditions that they believe cannot possibly occur. If such conditions occur, they indicate
* a serious flaw in the programmer's logic.
* 2 They allow the programmer to assure the TypeScript compiler of the truth of some condition that the compiler cannot itself infer.
* 3 They allow the author of an API to indicate to consumers of the API a serious misuse that should be corrected during development.
*
* Assertions should **never** be used to test for conditions - however unlikely - that could be expected to occur at run-time,
* such as failing to write to a file or load a resource over the network. If the condition asserted ever fails in a production environment,
* the programmer has made a serious mistake.
*
* Note that even when assertions are disabled, calls to `assert` remain in the code and their arguments will be evaluated at run-time.
* Therefore, if your condition or message requires computation, prefer to pass it as a function to prevent it from being evaluated when assertions are disabled.
*
* @param condition The condition that is asserted to be `true`. If the condition is more complex than a simple `boolean` variable, pass it as a function to prevent it from being evaluated when assertions are disabled.
* @param message An optional description of the condition being asserted, to be included in the exception if `condition` is `false`. If the message must be computed, pass it as a function to prevent it from being evaluated when assertions are disabled. Defaults to "Programmer Error".
* @throws Error containing the specified `message` if `condition` is `false`.
* @public
*/
export declare function assert(condition: boolean, msg?: string): asserts condition;
export declare function assert(condition: boolean | (() => boolean), message?: string | (() => string)): asserts condition;
//# sourceMappingURL=Assert.d.ts.map

@@ -11,18 +11,37 @@ "use strict";

exports.assert = void 0;
/**
* Asserts that a condition is `true`, and in development builds throws an error if it is not.
* This is an [assertion function](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions) that alters the
* behavior of the TypeScript compiler.
* @param condition The result of a boolean expression.
* @param msg An optional message to include in the thrown exception. Defaults to "Programmer Error".
* @throws Error containing the specified message if condition is false.
* @note This function should be used to validate conditions that should never realistically occur, or
* which indicate a misuse of the API which should be eliminated during development.
const assertionsEnabled = process.env.NODE_ENV === "development";
/** Asserts that a condition is `true` and - when enabled - throws an error if it is not.
* Assertions are enabled only if the build configuration defines `process.env.NODE_ENV` as `development` at build time.
*
* Assertions exist solely to assist programmers during development, in the following ways:
* 1 They allow the programmer to declare conditions that they believe cannot possibly occur. If such conditions occur, they indicate
* a serious flaw in the programmer's logic.
* 2 They allow the programmer to assure the TypeScript compiler of the truth of some condition that the compiler cannot itself infer.
* 3 They allow the author of an API to indicate to consumers of the API a serious misuse that should be corrected during development.
*
* Assertions should **never** be used to test for conditions - however unlikely - that could be expected to occur at run-time,
* such as failing to write to a file or load a resource over the network. If the condition asserted ever fails in a production environment,
* the programmer has made a serious mistake.
*
* Note that even when assertions are disabled, calls to `assert` remain in the code and their arguments will be evaluated at run-time.
* Therefore, if your condition or message requires computation, prefer to pass it as a function to prevent it from being evaluated when assertions are disabled.
*
* @param condition The condition that is asserted to be `true`. If the condition is more complex than a simple `boolean` variable, pass it as a function to prevent it from being evaluated when assertions are disabled.
* @param message An optional description of the condition being asserted, to be included in the exception if `condition` is `false`. If the message must be computed, pass it as a function to prevent it from being evaluated when assertions are disabled. Defaults to "Programmer Error".
* @throws Error containing the specified `message` if `condition` is `false`.
* @public
*/
function assert(condition, msg) {
if (!condition)
throw new Error(`Assert: ${msg !== null && msg !== void 0 ? msg : "Programmer Error"}`);
function assert(condition, message) {
if (!assertionsEnabled)
return;
if ("boolean" !== typeof condition)
condition = condition();
if (condition)
return;
message = message !== null && message !== void 0 ? message : "Programmer Error";
if ("string" !== typeof message)
message = message();
throw new Error(`Assert: ${message}`);
}
exports.assert = assert;
//# sourceMappingURL=Assert.js.map
/** @packageDocumentation
* @module Utils
*/
/**
* Asserts that a condition is `true`, and in development builds throws an error if it is not.
* This is an [assertion function](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions) that alters the
* behavior of the TypeScript compiler.
* @param condition The result of a boolean expression.
* @param msg An optional message to include in the thrown exception. Defaults to "Programmer Error".
* @throws Error containing the specified message if condition is false.
* @note This function should be used to validate conditions that should never realistically occur, or
* which indicate a misuse of the API which should be eliminated during development.
/** Asserts that a condition is `true` and - when enabled - throws an error if it is not.
* Assertions are enabled only if the build configuration defines `process.env.NODE_ENV` as `development` at build time.
*
* Assertions exist solely to assist programmers during development, in the following ways:
* 1 They allow the programmer to declare conditions that they believe cannot possibly occur. If such conditions occur, they indicate
* a serious flaw in the programmer's logic.
* 2 They allow the programmer to assure the TypeScript compiler of the truth of some condition that the compiler cannot itself infer.
* 3 They allow the author of an API to indicate to consumers of the API a serious misuse that should be corrected during development.
*
* Assertions should **never** be used to test for conditions - however unlikely - that could be expected to occur at run-time,
* such as failing to write to a file or load a resource over the network. If the condition asserted ever fails in a production environment,
* the programmer has made a serious mistake.
*
* Note that even when assertions are disabled, calls to `assert` remain in the code and their arguments will be evaluated at run-time.
* Therefore, if your condition or message requires computation, prefer to pass it as a function to prevent it from being evaluated when assertions are disabled.
*
* @param condition The condition that is asserted to be `true`. If the condition is more complex than a simple `boolean` variable, pass it as a function to prevent it from being evaluated when assertions are disabled.
* @param message An optional description of the condition being asserted, to be included in the exception if `condition` is `false`. If the message must be computed, pass it as a function to prevent it from being evaluated when assertions are disabled. Defaults to "Programmer Error".
* @throws Error containing the specified `message` if `condition` is `false`.
* @public
*/
export declare function assert(condition: boolean, msg?: string): asserts condition;
export declare function assert(condition: boolean | (() => boolean), message?: string | (() => string)): asserts condition;
//# sourceMappingURL=Assert.d.ts.map

@@ -8,17 +8,36 @@ /*---------------------------------------------------------------------------------------------

*/
/**
* Asserts that a condition is `true`, and in development builds throws an error if it is not.
* This is an [assertion function](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions) that alters the
* behavior of the TypeScript compiler.
* @param condition The result of a boolean expression.
* @param msg An optional message to include in the thrown exception. Defaults to "Programmer Error".
* @throws Error containing the specified message if condition is false.
* @note This function should be used to validate conditions that should never realistically occur, or
* which indicate a misuse of the API which should be eliminated during development.
const assertionsEnabled = process.env.NODE_ENV === "development";
/** Asserts that a condition is `true` and - when enabled - throws an error if it is not.
* Assertions are enabled only if the build configuration defines `process.env.NODE_ENV` as `development` at build time.
*
* Assertions exist solely to assist programmers during development, in the following ways:
* 1 They allow the programmer to declare conditions that they believe cannot possibly occur. If such conditions occur, they indicate
* a serious flaw in the programmer's logic.
* 2 They allow the programmer to assure the TypeScript compiler of the truth of some condition that the compiler cannot itself infer.
* 3 They allow the author of an API to indicate to consumers of the API a serious misuse that should be corrected during development.
*
* Assertions should **never** be used to test for conditions - however unlikely - that could be expected to occur at run-time,
* such as failing to write to a file or load a resource over the network. If the condition asserted ever fails in a production environment,
* the programmer has made a serious mistake.
*
* Note that even when assertions are disabled, calls to `assert` remain in the code and their arguments will be evaluated at run-time.
* Therefore, if your condition or message requires computation, prefer to pass it as a function to prevent it from being evaluated when assertions are disabled.
*
* @param condition The condition that is asserted to be `true`. If the condition is more complex than a simple `boolean` variable, pass it as a function to prevent it from being evaluated when assertions are disabled.
* @param message An optional description of the condition being asserted, to be included in the exception if `condition` is `false`. If the message must be computed, pass it as a function to prevent it from being evaluated when assertions are disabled. Defaults to "Programmer Error".
* @throws Error containing the specified `message` if `condition` is `false`.
* @public
*/
export function assert(condition, msg) {
if (!condition)
throw new Error(`Assert: ${msg !== null && msg !== void 0 ? msg : "Programmer Error"}`);
export function assert(condition, message) {
if (!assertionsEnabled)
return;
if ("boolean" !== typeof condition)
condition = condition();
if (condition)
return;
message = message !== null && message !== void 0 ? message : "Programmer Error";
if ("string" !== typeof message)
message = message();
throw new Error(`Assert: ${message}`);
}
//# sourceMappingURL=Assert.js.map
{
"name": "@itwin/core-bentley",
"version": "3.0.0-dev.109",
"version": "3.0.0-dev.112",
"description": "Bentley JavaScript core components",

@@ -25,4 +25,4 @@ "main": "lib/cjs/core-bentley.js",

"devDependencies": {
"@itwin/build-tools": "3.0.0-dev.109",
"@itwin/eslint-plugin": "3.0.0-dev.109",
"@itwin/build-tools": "3.0.0-dev.112",
"@itwin/eslint-plugin": "3.0.0-dev.112",
"@types/chai": "^4.1.4",

@@ -29,0 +29,0 @@ "@types/chai-as-promised": "^7",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc