plusone
plusone is a simple function that will return the increment of a value. What makes it special?
It will increment undefined to be 1 (null already increments to 1 just fine).
Why would you need that? Because of this:
var obj = {
bar: 'foo'
};
obj.foo = obj.foo + 1;
obj.bar = obj.bar ? obj.bar + 1 : 1;
obj.baz = typeof obj.baz !== 'undefined' ? obj.baz + 1 : 1;
obj.count = plusone( obj.count );
Installation
npm install plusone --save
Usage
var plusone = require( 'plusone' );
var i = 0;
i = plusone( i );
var obj = {};
obj.count = plusone( obj.count );
Contributing
Pull requests are very welcome! Just make sure your code:
-
Passes jshint given the included .jshintrc
-
Is beautified using jsbeautifier and the included .jsbeautifyrc
-
Has tests and passes them.
CHANGELOG
0.0.3
0.0.2
- Documentation updates
- A couple of more tests
0.0.1