utility ======= [![Build Status](https://secure.travis-ci.org/node-modules/utility.png)](http://travis-ci.org/node-modules/utility) [![Coverage Status](https://coveralls.io/repos/node-modules/utility/badge.png)](https://coveralls.io/r/node-modules/utility) [![NPM](https://nodei.co/npm/utility.png?downloads=true&stars=true)](https://nodei.co/npm/utility) ![logo](https://raw.github.com/node-modules/utility/master/logo.png) A collection of useful utilities. ## Install ```bash $ npm install utility ``` ## Usage ```js var utils = require('utility'); // md5 hash utils.md5('@Python发烧友'); // '1369e7668bc600f0d90c06f5e395d7a9' utils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e' // md5 hase output base64 utils.md5('苏千', 'base64'); // 'X3M8R8WKB31hJXECstREgQ==' // Object md5 hash utils.md5({foo: 'bar', bar: 'foo'}).should.equal(utils.md5({bar: 'foo', foo: 'bar'})); // sha1 hash utils.sha1('@Python发烧友'); // 'ed6a2381ad20f2cf7875fc04d52257380015b574' utils.sha1(new Buffer('')); // 'da39a3ee5e6b4b0d3255bfef95601890afd80709' // sha1 hase output base64 utils.sha1('苏千', 'base64'); // 'Ckr/a6tjS5wvmbcfJel2kh/N5aU=' // Object sha1 hash utils.sha1({foo: 'bar', bar: 'foo'}).should.equal(utils.sha1({bar: 'foo', foo: 'bar'})); // hmac // hmac-sha1 with base64 output encoding utils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0=' // base64 encode utils.base64encode('你好¥'); // '5L2g5aW977+l' utils.base64decode('5L2g5aW977+l') // '你好¥' // urlsafe base64 encode utils.base64encode('你好¥', true); // '5L2g5aW977-l' utils.base64decode('5L2g5aW977-l', true); // '你好¥' // empty function process.nextTick(utils.noop); function foo(callback) { callback = callback || utils.noop; } // html escape utils.escape('