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

@invisible/assert

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@invisible/assert

Proxy for assert that accepts custom Errors

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

@invisible/assert

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

Package last updated on 21 Sep 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