Socket
Socket
Sign inDemoInstall

@blackglory/errors

Package Overview
Dependencies
0
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

lib/es2015/assert.d.ts

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## [1.1.0](https://github.com/BlackGlory/errors/compare/v1.0.0...v1.1.0) (2021-02-03)
### Features
* add assert, refute, AssertionError ([52baf47](https://github.com/BlackGlory/errors/commit/52baf47a708514b4028354f9b25e307d3b81416f))
## [1.0.0](https://github.com/BlackGlory/errors/compare/v0.1.5...v1.0.0) (2021-02-03)

@@ -7,0 +14,0 @@

@@ -16,2 +16,5 @@ (function (global, factory) {

class AssertionError extends CustomError {
}
function normalize(err) {

@@ -26,5 +29,24 @@ var _a;

/**
* @throws {ExpectedError}
*/
function refute(condition, message) {
if (condition)
throw new ExpectedError(message);
}
/**
* @throws {AssertionError}
*/
function assert(condition, message) {
if (!condition)
throw new AssertionError(message);
}
exports.AssertionError = AssertionError;
exports.CustomError = CustomError;
exports.ExpectedError = ExpectedError;
exports.assert = assert;
exports.normalize = normalize;
exports.refute = refute;

@@ -31,0 +53,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

2

dist/es2015/index.umd.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Errors={})}(this,(function(e){"use strict";class t extends Error{get name(){return this.constructor.name}}e.CustomError=t,e.ExpectedError=class extends t{},e.normalize=function(e){var t;return{name:e.name,message:e.message,stack:null!==(t=e.stack)&&void 0!==t?t:null}},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Errors={})}(this,(function(e){"use strict";class t extends Error{get name(){return this.constructor.name}}class n extends t{}class r extends t{}e.AssertionError=r,e.CustomError=t,e.ExpectedError=n,e.assert=function(e,t){if(!e)throw new r(t)},e.normalize=function(e){var t;return{name:e.name,message:e.message,stack:null!==(t=e.stack)&&void 0!==t?t:null}},e.refute=function(e,t){if(e)throw new n(t)},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.min.js.map

@@ -16,2 +16,5 @@ (function (global, factory) {

class AssertionError extends CustomError {
}
function normalize(err) {

@@ -26,5 +29,24 @@ var _a;

/**
* @throws {ExpectedError}
*/
function refute(condition, message) {
if (condition)
throw new ExpectedError(message);
}
/**
* @throws {AssertionError}
*/
function assert(condition, message) {
if (!condition)
throw new AssertionError(message);
}
exports.AssertionError = AssertionError;
exports.CustomError = CustomError;
exports.ExpectedError = ExpectedError;
exports.assert = assert;
exports.normalize = normalize;
exports.refute = refute;

@@ -31,0 +53,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Errors={})}(this,(function(e){"use strict";class t extends Error{get name(){return this.constructor.name}}e.CustomError=t,e.ExpectedError=class extends t{},e.normalize=function(e){var t;return{name:e.name,message:e.message,stack:null!==(t=e.stack)&&void 0!==t?t:null}},Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Errors={})}(this,(function(e){"use strict";class t extends Error{get name(){return this.constructor.name}}class n extends t{}class r extends t{}e.AssertionError=r,e.CustomError=t,e.ExpectedError=n,e.assert=function(e,t){if(!e)throw new r(t)},e.normalize=function(e){var t;return{name:e.name,message:e.message,stack:null!==(t=e.stack)&&void 0!==t?t:null}},e.refute=function(e,t){if(e)throw new n(t)},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.min.js.map
export * from './custom-error';
export * from './expected-error';
export * from './assertion-error';
export * from './normalize';
export * from './refute';
export * from './assert';

@@ -15,3 +15,6 @@ "use strict";

__exportStar(require("./expected-error"), exports);
__exportStar(require("./assertion-error"), exports);
__exportStar(require("./normalize"), exports);
__exportStar(require("./refute"), exports);
__exportStar(require("./assert"), exports);
//# sourceMappingURL=index.js.map
export * from './custom-error';
export * from './expected-error';
export * from './assertion-error';
export * from './normalize';
export * from './refute';
export * from './assert';

@@ -15,3 +15,6 @@ "use strict";

__exportStar(require("./expected-error"), exports);
__exportStar(require("./assertion-error"), exports);
__exportStar(require("./normalize"), exports);
__exportStar(require("./refute"), exports);
__exportStar(require("./assert"), exports);
//# sourceMappingURL=index.js.map
{
"name": "@blackglory/errors",
"version": "1.0.0",
"version": "1.1.0",
"description": "Common errors",

@@ -54,2 +54,3 @@ "files": [

"npm-run-all": "^4.1.5",
"return-style": "^0.11.5",
"rimraf": "^3.0.2",

@@ -61,2 +62,3 @@ "rollup": "^2.38.4",

"tscpaths": "^0.0.9",
"tsd": "^0.14.0",
"typescript": "^4.1.3"

@@ -63,0 +65,0 @@ },

@@ -39,2 +39,8 @@ # errors

### AssertionError
```ts
class AssertionError extends CustomError {}
```
### normalize

@@ -45,1 +51,21 @@

```
### assert
```ts
/**
* @throws {AssertionError}
*/
function assert(condition: unknown, message?: string): asserts condition
```
### refute
```ts
/**
* @throws {ExpectedError}
*/
function refute(condition: unknown, message?: string): void
```
A negative assertion, expects the condition to be falsy.

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

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

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

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc