node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org ยป



A module to throw errors if conditions aren't met.


You must use npm 2.7.0 or higher because of the scoped package name.

$ npm init
$ npm install @mitchallen/demand --save


var demand = require('@mitchallen/demand');

database.connect(uri, function(err,db) {


	demand.notNull(db,"ERROR: db is null");


notNull(object, message)

Will throw an error containing the message parameter if the object parameter is null;


Will throw an error if the err object is not null. The error will use the string from err.message.


To test, go to the root folder and type (sans $):

$ npm test



In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Version History

Version 0.1.3 release notes

  • notNull now distinguishes between null and zero

Version 0.1.2 release notes

  • Added pushTo to Gruntfile

Version 0.1.1 release notes

  • Fixed type-o in README example

Version 0.1.0 release notes

  • Initial release