Skip to content

PavelDymkov/logical-not

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logical NOT Function

The not function is an alphabetic analogue of the unary operator !. It is used to increase the readability of the code.

Usage:

import not from "logical-not";
// or import { not } from "logical-not";

if (not("foo".includes("bar"))) {
    console.log("baz");
}

Typescript support

function main(): void {
    const div = document.querySelector("div");
    const span = document.querySelector("span"); 
    
    // now div is HTMLDivElement | null
    // span is HTMLSpanElement | null

    if (not(div)) return;

    // now div is HTMLDivElement
    div.textContent;
    
    // need to use optional chaining
    span?.textContent;
}

License

MIT License (see LICENSE file).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published