Socket
Socket
Sign inDemoInstall

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


Version published
Maintainers
3
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 30 Sep 2016

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