0.0.2 • Published 8 years ago
nutty-util v0.0.2
nutty-util
Utilities for cli applications and nutty middlewares
Installation
Run the following command on your project folder:
npm install --save nutty-util
API
Include the library on your project:
var util = require('nutty-util');
util.is.{TYPE}(obj)
Returns true
or false
if the provided object is the specified type.
//Check for undefined
util.is.undef(a); // --> true
//Check for boolean
util.is.boolean(true); // --> true
util.is.boolean(1); // --> false
util.is.boolean('false'); // --> false
//Check for string
util.is.string('my string'); // --> true
util.is.string(0.987); // --> false
//Check if string is in lower or upper case
util.is.lowerCase('my string'); // --> true
util.is.upperCase('MY string'); // --> false
//Check for number
util.is.num('0'); // --> false
//Check for integer
util.is.int(0.12); // --> false
//Check for null
util.is.null(null); // --> true
new util.file(path, opt)
Returns an instance of a floby object.
var file = new util.file('/path/to/my/file.txt', { encoding: 'utf8' });
util.template(str, obj)
Compile a string template.
var str = util.template('My car is {color}.', { color: 'blue' }); //--> My car is blue.
License
MIT LICENSE © Josemi Juanes.