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

core-assert

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

core-assert

Node.js `assert` as a standalone module

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
95K
decreased by-33.39%
Maintainers
3
Weekly downloads
 
Created

What is core-assert?

The core-assert npm package provides a set of assertion functions for verifying invariants in your code. It is commonly used in testing to ensure that code behaves as expected.

What are core-assert's main functionalities?

assert.ok

The assert.ok function tests if a value is truthy. If the value is not truthy, it throws an AssertionError.

const assert = require('core-assert');
assert.ok(true); // No error
assert.ok(false); // Throws an AssertionError

assert.equal

The assert.equal function tests shallow, coercive equality between two values using the == operator. If the values are not equal, it throws an AssertionError.

const assert = require('core-assert');
assert.equal(1, 1); // No error
assert.equal(1, 2); // Throws an AssertionError

assert.deepEqual

The assert.deepEqual function tests for deep equality between two objects. If the objects are not deeply equal, it throws an AssertionError.

const assert = require('core-assert');
assert.deepEqual({a: 1}, {a: 1}); // No error
assert.deepEqual({a: 1}, {a: 2}); // Throws an AssertionError

assert.throws

The assert.throws function tests if a function throws an error. If the function does not throw an error, it throws an AssertionError.

const assert = require('core-assert');
assert.throws(() => { throw new Error('error'); }, Error); // No error
assert.throws(() => { }, Error); // Throws an AssertionError

Other packages similar to core-assert

Keywords

FAQs

Package last updated on 08 Nov 2018

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