New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

nanoassert

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanoassert

Nanoscale assertion module

latest
Source
npmnpm
Version
3.1.0
Version published
Weekly downloads
644K
6.08%
Maintainers
1
Weekly downloads
 
Created
Source

nanoassert

NPM

Nanoscale assertion module

Usage

const assert = require('nanoassert')

assert(a !== b, `${a} !== ${b}`)

API

assert(predicate, [message])

Assert that predicate is truthy, otherwise throw AssertionError with optional message. In Javascript runtimes that support Error.captureStackTrace, you will get a nicer stack trace with this error. If you want friendlier messages you can use template strings to show the assertion made like in the example above.

Why

I like to write public facing code very defensively, but have reservations about the size incurred by the assert module. I only use the top-level assert method anyway.

nanoassert@^1.1.0

Docs for the previous version, which is used by many modules on npm, can be found here

nanoassert@^3.0.0

Modernise nanoassert some, and add the small type definition from DefinitelyTyped. Functionally there should be no changes for most users, but the name property of the AssertionError is no longer set on the prototype, and newer syntax is employed, which might break some downstream modules.

Thank you to the folks that created and maintained the original type definitions.

Install

npm install nanoassert

License

ISC

Keywords

assert

FAQs

Package last updated on 12 Mar 2026

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