Skip to content

Wrap an object to make its methods lazily evaluate.

Notifications You must be signed in to change notification settings

testingrequired/lazy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@testingrequired/lazy

Wrap an object to make its methods lazily evaluate.

Installation

$ npm i @testingrequired/lazy

Usage

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

const lazyAssert = Lazy.of(assert);

lazyAssert.ok(false); // Does nothing
lazyAssert.ok(false)(); // Runs assertion

// This also works
const okFn = lazyAssert.ok(false); // Does nothing
okFn(); // Runs assertion

// Works with functions too
const hello = Lazy.fn(name => console.log(`Hello ${name}`));
const helloWorld = hello("World"); // Does nothing
const helloWorld(); // Hello World

About

Wrap an object to make its methods lazily evaluate.

Resources

Stars

Watchers

Forks

Packages

No packages published