Utility that provides different types of empty objects. All objects returned by this library are immutable (made so using Object.freeze) unless the NODE_ENV environment variable is set to 'production'.
Installation
The library is written for CommonJS environments such as Node and works beautifully in the browser using something like Browserify.
To install, make sure you have Node installed, then, in your project directory, run:
$ npm install empty
API
var empty = require('empty');
empty.object
var emptyObject = empty.object;// orvar emptyObject = require('empty/object');console.log(emptyObject);// {}
empty.array
var emptyArray = empty.array;// orvar emptyArray = require('empty/array');console.log(emptyArray);// []
empty.func
var emptyFunction = empty.func;// orvar emptyFunction = require('empty/function');console.log(emptyFunction);// function () {}
empty.functionThatReturns
var functionThatReturns = empty.functionThatReturns;// orvar functionThatReturns = require('empty/functionThatReturns');console.log(functionThatReturns('foo')());// 'foo'
empty.functionThatReturnsTrue
var functionThatReturnsTrue = empty.functionThatReturnsTrue;// orvar functionThatReturnsTrue = require('empty/functionThatReturnsTrue');console.log(functionThatReturnsTrue());// true
empty.functionThatReturnsFalse
var functionThatReturnsFalse = empty.functionThatReturnsFalse;// orvar functionThatReturnsFalse = require('empty/functionThatReturnsFalse');console.log(functionThatReturnsFalse());// false
empty.functionThatReturnsNull
var functionThatReturnsNull = empty.functionThatReturnsNull;// orvar functionThatReturnsNull = require('empty/functionThatReturnsNull');console.log(functionThatReturnsNull());// null