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

defekt

Package Overview
Dependencies
Maintainers
6
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

defekt - npm Package Compare versions

Comparing version 2.1.0 to 3.0.0

build/lib/defekt.d.ts

13

package.json
{
"name": "defekt",
"version": "2.1.0",
"version": "3.0.0",
"description": "defekt is custom errors made simple.",

@@ -17,5 +17,10 @@ "contributors": [

"email": "mail@michael-scherer.net"
},
{
"name": "Hannes Leutloff",
"email": "hannes.leutloff@thenativeweb.io"
}
],
"main": "lib/defekt.js",
"main": "build/lib/defekt.js",
"types": "build/lib/defekt.d.ts",
"dependencies": {

@@ -25,4 +30,4 @@ "humanize-string": "2.1.0"

"devDependencies": {
"assertthat": "3.2.0",
"roboter": "6.1.0"
"assertthat": "4.0.1",
"roboter": "7.1.0"
},

@@ -29,0 +34,0 @@ "repository": {

@@ -7,2 +7,12 @@ # defekt

## Status
| Category | Status |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| Version | [![npm](https://img.shields.io/npm/v/defekt)](https://www.npmjs.com/package/defekt) |
| Dependencies | ![David](https://img.shields.io/david/thenativeweb/defekt) |
| Dev dependencies | ![David](https://img.shields.io/david/dev/thenativeweb/defekt) |
| Build | [![CircleCI](https://img.shields.io/circleci/build/github/thenativeweb/defekt)](https://circleci.com/gh/thenativeweb/defekt/tree/master) |
| License | ![GitHub](https://img.shields.io/github/license/thenativeweb/defekt) |
## Installation

@@ -19,13 +29,19 @@

```javascript
const defekt = require('defekt');
const defekt = require('defekt').default;
```
Then call the `defekt` function and hand over an array of custom error names that you would like to have created:
If you use TypeScript, use the following code instead:
```typescript
import defekt from 'defekt';
```
Then call the `defekt` function and hand over an object of custom error configurations that you would like to have created. In this object each key is the name for an error and the corresponding value is the error's configuration.
```javascript
const errors = defekt([
'ArgumentNull',
'InvalidOperation',
'...'
]);
const errors = defekt({
ArgumentNull: {},
InvalidOperation: {},
// ...
});
```

@@ -68,14 +84,12 @@

From time to time, you may want to provide custom error codes. For that specify an object with a `name` and a `code` property instead of only providing the error name:
From time to time, you may want to provide custom error codes. For that specify a `code` property on the configuration object:
```javascript
const errors = defekt([
{ name: 'ArgumentNull', code: 'ARGNULL' },
{ name: 'InvalidOperation', code: 'INVALOP' },
{ name: '...', code: '...' }
]);
const errors = defekt({
ArgumentNull: { code: 'ARGNULL' },
InvalidOperation: { code: 'INVALOP' }
// ...
});
```
Please note that you can mix both definition types arbitrarily.
## Running the build

@@ -88,12 +102,1 @@

```
## License
The MIT License (MIT)
Copyright (c) 2015-2019 the native web.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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