Socket
Socket
Sign inDemoInstall

@invisible/assert

Package Overview
Dependencies
3
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @invisible/assert

Proxy for assert that accepts custom Errors


Version published
Maintainers
5
Created

Readme

Source

@invisible/assert

CircleCI

Assertion library to allow one to throw custom errors.

@invisible/assert 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.

@invisible/assert throws Custom Errors properly, which is nice

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

Stack-trace trimmed for readability.

Installation

npm install @invisible/assert

NB: 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

Last updated on 29 Sep 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc