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

new-error

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

new-error - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

2

build/error-types/BaseError.d.ts

@@ -17,2 +17,4 @@ import ExtendableError from 'es6-error';

protected _config: IBaseErrorConfig;
protected _hasMetadata: boolean;
protected _hasSafeMetadata: boolean;
constructor(message: string, config?: IBaseErrorConfig);

@@ -19,0 +21,0 @@ /**

@@ -17,2 +17,4 @@ "use strict";

this._metadata = {};
this._hasMetadata = false;
this._hasSafeMetadata = false;
this._config = config || {};

@@ -156,2 +158,3 @@ }

withMetadata(metadata) {
this._hasMetadata = true;
this._metadata = {

@@ -177,2 +180,4 @@ ...this._metadata,

withSafeMetadata(metadata) {
this._hasMetadata = true;
this._hasSafeMetadata = true;
this._safeMetadata = {

@@ -209,2 +214,7 @@ ...this._safeMetadata,

};
if (!this._hasSafeMetadata &&
!this._hasMetadata &&
this._config.omitEmptyMetadata) {
delete data.meta;
}
Object.keys(data).forEach(item => {

@@ -240,2 +250,5 @@ // remove undefined items

};
if (!this._hasSafeMetadata && this._config.omitEmptyMetadata) {
delete data.meta;
}
Object.keys(data).forEach(item => {

@@ -302,3 +315,3 @@ // remove undefined items

else {
errInstance.withMetadata(data.meta);
errInstance.withMetadata(data.meta || {});
}

@@ -305,0 +318,0 @@ }

@@ -211,2 +211,6 @@ /**

toJSONSafeFieldsToOmit?: string[];
/**
* If the metadata has no data defined, remove the `meta` property on `toJSON` / `toJSONSafe`
*/
omitEmptyMetadata?: boolean;
}

@@ -213,0 +217,0 @@ /**

@@ -0,1 +1,9 @@

## 1.2.2 - Mon Mar 08 2021 21:06:07
**Contributor:** Theo Gravity
- Add option to not include empty metadata on serialization (#9)
This adds `omitEmptyMetadata` to the `BaseError` configuration.
## 1.2.1 - Mon Mar 08 2021 20:33:41

@@ -2,0 +10,0 @@

2

package.json
{
"name": "new-error",
"version": "1.2.1",
"version": "1.2.2",
"description": "A production-grade error creation and serialization library designed for Typescript",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -489,2 +489,6 @@ # new-error

toJSONSafeFieldsToOmit?: string[]
/**
* If the metadata has no data defined, remove the `meta` property on `toJSON` / `toJSONSafe`.
*/
omitEmptyMetadata?: boolean
}

@@ -491,0 +495,0 @@ ```

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