Socket
Socket
Sign inDemoInstall

serialize-error

Package Overview
Dependencies
1
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0 to 4.1.0

53

index.d.ts
import {Primitive, JsonObject} from 'type-fest';
export type ErrorObject = {
name?: string;
stack?: string;
message?: string;
code?: string;
} & JsonObject;
declare namespace serializeError {
type ErrorObject = {
name?: string;
stack?: string;
message?: string;
code?: string;
} & JsonObject;
}
/**
Serialize an error into a plain object.
declare const serializeError: {
/**
Serialize an error into a plain object.
@example
```
import serializeError from 'serialize-error';
@example
```
import serializeError = require('serialize-error');
const error = new Error('🦄');
const error = new Error('🦄');
console.log(error);
//=> [Error: 🦄]
console.log(error);
//=> [Error: 🦄]
console.log(serializeError(error));
//=> {name: 'Error', message: '🦄', stack: 'Error: 🦄\n at Object.<anonymous> …'}
```
*/
export default function serializeError<ErrorType>(error: ErrorType): ErrorType extends Primitive ? ErrorType : ErrorObject;
console.log(serializeError(error));
//=> {name: 'Error', message: '🦄', stack: 'Error: 🦄\n at Object.<anonymous> …'}
```
*/
<ErrorType>(error: ErrorType): ErrorType extends Primitive
? ErrorType
: serializeError.ErrorObject;
// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function serializeError<ErrorType>(
// error: ErrorType
// ): ErrorType extends Primitive ? ErrorType : ErrorObject;
// export = serializeError;
default: typeof serializeError;
};
export = serializeError;

@@ -57,2 +57,3 @@ 'use strict';

module.exports = serializeError;
// TODO: Remove this for the next major release
module.exports.default = serializeError;
{
"name": "serialize-error",
"version": "4.0.0",
"version": "4.1.0",
"description": "Serialize an error into a plain object",

@@ -16,3 +16,3 @@ "license": "MIT",

"scripts": {
"test": "xo && ava && tsd-check"
"test": "xo && ava && tsd"
},

@@ -36,6 +36,6 @@ "files": [

"devDependencies": {
"ava": "^1.3.1",
"tsd-check": "^0.5.0",
"ava": "^1.4.1",
"tsd": "^0.7.1",
"xo": "^0.24.0"
}
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc