null

2.0.0 • Public • Published

null

Null all of the things! This package was originally created as a joke, but hey now it actually does something non-trivial.

If you ever use null for logic tests, you can try using a Symbol instead via the NullRef library provided by this package.

This package provides for a NULL constant that is a Symbol from the Global Symbol Registry, as well as convenience methods for testing, casting, and comparing values.

Usage

Require and reference what you need:

const nullref   = require('null'); // note that the variable name should not be null, here we use nullref
const nulltest  = nullref.lib; // load the full library of convenience features
 
const isNull    = nullref.isNull // or just load the main ones you want (checks for null or NULL)
const isNullRef = nullref.isNullRef // checks for NULL only
 
const NULL = nullref(); // NULL symbol instance (singleton);

Consume and use as needed.

let x = null;
 
//returns true if x is null or NULL
if( nulltest.is(x) ) //do something
if( isNull(x) ) // same as above
 
//cast a variable to NULL if it is null or NULL, otherwise it returns itself
if( NULL === nulltest.to(x) ) // do something
 

Readme

Keywords

Package Sidebar

Install

npm i null

Weekly Downloads

1,219

Version

2.0.0

License

MIT

Unpacked Size

3.86 kB

Total Files

4

Last publish

Collaborators

  • qodeninja