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

basic-assert

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-assert

The simplest possible assert

  • 0.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

basic-assert

Basically the simplest assert library you can get.

Usage

assert(something truthy)
assert.not(something falsy)
assert.is(something, expected)
assert.isnt(something, unexpected)

// Deep equality - circular data structures not supported
assert.eq(something, expected)
assert.neq(something, unexpected)

basic-assert is smart enough to display the offending source line. It also works with CoffeeScript (version >= 1.6.2).

How it looks like:

% ./test

Error: Got "[1,2,3]",
Expected:  "[1,2,3,4]"

File: test
Line: 24

assert.eq([1,2,3], [1,2,3,4]);
	   ^

	   <anonymous> (test:24:8)
	   Module._compile (module.js:456:26)
	   Module._extensions..js (module.js:474:10)
	   Module.load (module.js:356:32)
	   Module._load (module.js:312:12)
	   Module.runMain (module.js:497:10)
	   startup (node.js:119:16)
	   <anonymous> (node.js:901:3)

Normally, assert will just terminate the process when something unexpected happens. If you want it to go on, you can do:

assert.fatal = false

Shortcomings

Other JavaScript implementations than V8 are not supported.

Keywords

FAQs

Package last updated on 06 Dec 2013

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