Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

testingrequired/lazy-assert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@testingrequired/lazy-assert

A lazy wrapper around Node's assert module.

Install

$ npm i -D @testingrequired/lazy-assert

Usage

import assert from "@testingrequired/lazy-assert";

assert(1 === 2, "They don't equal"); // Returns a function

assert(1 === 2, "They don't equal")(); // Runs assertion

Why?

Lazy assertions are essential for building something like multi assert assertions.

import assert from "@testingrequired/lazy-assert";

const point = {
  y: 10
};

// Creating assertions doesn't run them
const asserts = [
  assert(point.x, "x not defined", assert(point.y, "y not defined"))
];

// Some multi assert implementation
multiAssert(...asserts, "Something is wrong");

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published