Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.
/ notnot Public archive

A simple npm package that implements the .not property in all objects

License

Notifications You must be signed in to change notification settings

ByPort/notnot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

notnot

A simple npm package that implements the .not property in all objects (except null and undefined).

⚠️ ATTENTION, MONKEY PATCHING

Reason

Sometimes there is a need to negate the value of a very long chain expression. Semantically, only the last property is negated from the whole expression, but the ! sign is placed first in the expression. Example:

// Checks if the first task is not completed
!JSON.parse(window.localStorage.getItem('tasks'))[0].completed

An option with a negation near the negated property is more conveniently readable:

JSON.parse(window.localStorage.getItem('tasks'))[0].not.completed
// or even
JSON.parse(window.localStorage.getItem('tasks'))[0].completed.not

This is the essence of this package.

Getting started

Install the package via npm:

npm install --save notnot

Then import the package in your project:

import 'notnot';
// or
require('notnot');

Remember that the package implements the .not property in the Object.prototype and this will apply to the whole context after import.

About

A simple npm package that implements the .not property in all objects

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published