package
Utility that provides different types of empty objects.
npm install emptyGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 4 packages.
307.0 kB
Includes dependencies.
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'.
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 emptyvar empty = require('empty');empty.objectvar emptyObject = empty.object;
// or
var emptyObject = require('empty/object');
console.log(emptyObject);
// {}empty.arrayvar emptyArray = empty.array;
// or
var emptyArray = require('empty/array');
console.log(emptyArray);
// []empty.funcvar emptyFunction = empty.func;
// or
var emptyFunction = require('empty/function');
console.log(emptyFunction);
// function () {}empty.functionThatReturnsvar functionThatReturns = empty.functionThatReturns;
// or
var functionThatReturns = require('empty/functionThatReturns');
console.log(functionThatReturns('foo')());
// 'foo'empty.functionThatReturnsTruevar functionThatReturnsTrue = empty.functionThatReturnsTrue;
// or
var functionThatReturnsTrue = require('empty/functionThatReturnsTrue');
console.log(functionThatReturnsTrue());
// trueempty.functionThatReturnsFalsevar functionThatReturnsFalse = empty.functionThatReturnsFalse;
// or
var functionThatReturnsFalse = require('empty/functionThatReturnsFalse');
console.log(functionThatReturnsFalse());
// falseempty.functionThatReturnsNullvar functionThatReturnsNull = empty.functionThatReturnsNull;
// or
var functionThatReturnsNull = require('empty/functionThatReturnsNull');
console.log(functionThatReturnsNull());
// nullempty.functionThatReturnsThisvar functionThatReturnsThis = empty.functionThatReturnsThis;
// or
var functionThatReturnsThis = require('empty/functionThatReturnsThis');
console.log(functionThatReturnsThis.call({a: 1}));
// {a: 1}empty.functionThatReturnsArgumentvar functionThatReturnsArgument = empty.functionThatReturnsArgument;
// or
var functionThatReturnsArgument = require('empty/functionThatReturnsArgument');
console.log(functionThatReturnsArgument('foo'));
// 'foo'Many thanks to Arturo for the name on NPM. The original package repository can be found at here.