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

avow

Package Overview
Dependencies
Maintainers
4
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

avow

Proxy for assert that accepts custom Errors

  • 4.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
Maintainers
4
Weekly downloads
 
Created
Source

avow

Assertion library to allow one to throw custom errors.

avow uses ES2015 Proxies to intercept calls to assert. All methods of assert are available, and it is compatible with both Node.js's standard assertion library and the one on npm.

Motivation

To allow assert to throw custom errors.

Example

assert encapsulates Custom Errors under an AssertionError, which sucks

const assert = require('assert')
assert(false, Error('yohoo')

{ AssertionError: Error: yohoo
    at Object.<anonymous> (/tmp/a/index.js:2:1)
  name: 'AssertionError',
  actual: false,
  expected: true,
  operator: '==',
  message: 
   Error: yohoo
       at Object.<anonymous> (/tmp/a/index.js:2:15)
  generatedMessage: false }

Stack-trace trimmed for readability.

avow throws Custom Errors properly, which is nice

const avow = require('avow')
avow(false, Error('yohoo'))
Error: yohoo
    at Object.<anonymous> (/tmp/a/index.js:2:16)

Stack-trace trimmed for readability.

Installation

Make sure assert is installed.

The npm library assert is not a dependency in package.json in order to allow one to use Node.js's standard assert library.

Keywords

FAQs

Package last updated on 17 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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