diff --git a/.travis.yml b/.travis.yml
index 9097a94..a44cd26 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,4 @@
language: node_js
node_js:
- '0.10'
- - '0.8'
script: make test-coveralls
diff --git a/Makefile b/Makefile
index 1bcf55a..d419576 100644
--- a/Makefile
+++ b/Makefile
@@ -28,4 +28,3 @@ test-coveralls: test
test-all: test test-cov
.PHONY: test
-
diff --git a/README.md b/README.md
index be63634..baf01a8 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
cnpmjs.org
=======
-[](http://travis-ci.org/fengmk2/cnpmjs.org) [](https://coveralls.io/r/fengmk2/cnpmjs.org) [](https://drone.io/github.com/fengmk2/cnpmjs.org/latest)
+[](http://travis-ci.org/fengmk2/cnpmjs.org) [](https://coveralls.io/r/fengmk2/cnpmjs.org)
[](https://nodei.co/npm/cnpmjs.org/)
diff --git a/controllers/registry/module.js b/controllers/registry/module.js
index 5482da5..49c9507 100644
--- a/controllers/registry/module.js
+++ b/controllers/registry/module.js
@@ -19,6 +19,7 @@ var debug = require('debug')('cnpmjs.org:controllers:registry:module');
var path = require('path');
var fs = require('fs');
var crypto = require('crypto');
+var eventproxy = require('eventproxy');
var config = require('../../config');
var Module = require('../../proxy/module');
@@ -28,40 +29,43 @@ exports.show = function (req, res, next) {
if (err || rows.length === 0) {
return next(err);
}
- var latest;
- for (var i = 0; i < rows.length; i++) {
- var row = rows[i];
- if (row.version === 'latest') {
- latest = row;
- break;
- }
+ var nextMod = rows[0];
+ var latest = rows[1];
+ var startIndex = 1;
+ if (nextMod.version !== 'next') {
+ // next create fail
+ latest = nextMod;
+ startIndex = 0;
+ nextMod = null;
}
+
if (!latest) {
- return next();
+ latest = nextMod;
}
var distTags = {};
var versions = {};
var times = {};
var attachments = {};
- for (var i = 0; i < rows.length; i++) {
+ for (var i = startIndex; i < rows.length; i++) {
var row = rows[i];
var pkg = row.package;
- if (!pkg.version || pkg.version === 'latest') {
- continue;
- }
-
versions[pkg.version] = pkg;
times[pkg.version] = row.gmt_modified;
}
- if (latest.package.version || latest.package.version !== 'init') {
- distTags['latest'] = latest.package.version;
+ if (latest.package.version && latest.package.version !== 'next') {
+ distTags.latest = latest.package.version;
+ }
+
+ var rev = '';
+ if (nextMod) {
+ rev = String(nextMod.id);
}
var info = {
_id: latest.name,
- _rev: String(latest.id),
+ _rev: rev,
name: latest.name,
description: latest.package.description,
versions: versions,
@@ -88,6 +92,9 @@ exports.upload = function (req, res, next) {
var name = req.params.name;
var id = Number(req.params.rev);
var filename = req.params.filename;
+ var version = filename.substring(filename.indexOf('-') + 1);
+ version = version.replace(/\.tgz$/, '');
+ // save version on pkg upload
debug('%s: upload %s, file size: %d', username, req.url, length);
Module.getById(id, function (err, mod) {
@@ -98,12 +105,20 @@ exports.upload = function (req, res, next) {
return item.name === username;
});
if (match.length === 0 || mod.name !== name) {
- return res.json(401, {
- error: 'noperms',
+ return res.json(403, {
+ error: 'no_perms',
reason: 'Current user can not publish this module'
});
}
+ if (mod.version !== 'next') {
+ // rev wrong
+ return res.json(403, {
+ error: 'rev_wrong',
+ reason: 'rev not match next module'
+ });
+ }
+
var filepath = path.join(config.uploadDir, filename);
var ws = fs.createWriteStream(filepath);
var shasum = crypto.createHash('sha1');
@@ -115,8 +130,8 @@ exports.upload = function (req, res, next) {
});
ws.on('finish', function () {
if (dataSize !== length) {
- return res.json(401, {
- error: 'wrongsize',
+ return res.json(403, {
+ error: 'size_wrong',
reason: 'Header size ' + length + ' not match download size ' + dataSize,
});
}
@@ -127,12 +142,14 @@ exports.upload = function (req, res, next) {
size: length
};
mod.package.dist = dist;
- debug('%s module: save file to %s, size: %d, sha1: %s, dist: %j', id, filepath, length, shasum, dist);
+ mod.package.version = version;
+ debug('%s module: save file to %s, size: %d, sha1: %s, dist: %j, version: %s',
+ id, filepath, length, shasum, dist, version);
Module.update(mod, function (err, result) {
if (err) {
return next(err);
}
- res.json(201, {ok: true, rev: String(result.id), date: result.gmt_modified});
+ res.json(201, {ok: true, rev: String(result.id)});
});
});
});
@@ -142,14 +159,14 @@ exports.updateLatest = function (req, res, next) {
var username = req.session.name;
var name = req.params.name;
var version = req.params.version;
- Module.get(name, 'latest', function (err, mod) {
+ Module.get(name, 'next', function (err, nextMod) {
if (err) {
return next(err);
}
- if (!mod) {
+ if (!nextMod) {
return next();
}
- var match = mod.package.maintainers.filter(function (item) {
+ var match = nextMod.package.maintainers.filter(function (item) {
return item.name === username;
});
if (match.length === 0) {
@@ -159,32 +176,39 @@ exports.updateLatest = function (req, res, next) {
});
}
- var body = req.body;
+ // check version if not match pkg upload
+ if (nextMod.package.version !== version) {
+ return res.json(403, {
+ error: 'version_wrong',
+ reason: 'version not match'
+ });
+ }
- mod.version = version;
- mod.author = username;
- body.dist = mod.package.dist;
- body.maintainers = mod.package.maintainers;
+ var body = req.body;
+ nextMod.version = version;
+ nextMod.author = username;
+ body.dist = nextMod.package.dist;
+ body.maintainers = nextMod.package.maintainers;
if (!body.author) {
body.author = {
name: username,
email: req.session.email,
};
}
- mod.package = body;
- debug('update %s:%s %j', mod.package.name, mod.package.version, mod.package.dist);
+ nextMod.package = body;
+ debug('update %s:%s %j', nextMod.package.name, nextMod.package.version, nextMod.package.dist);
// change latest to version
- Module.update(mod, function (err) {
+ Module.update(nextMod, function (err) {
if (err) {
return next(err);
}
// add a new latest version
- mod.version = 'latest';
- Module.add(mod, function (err, result) {
+ nextMod.version = 'next';
+ Module.add(nextMod, function (err, result) {
if (err) {
return next(err);
}
- res.json(201, {ok: true, rev: String(result.id), date: result.gmt_modified});
+ res.json(201, {ok: true, rev: String(result.id)});
});
});
});
@@ -199,59 +223,65 @@ exports.add = function (req, res, next) {
return item.name === username;
});
if (match.length === 0) {
- return res.json(401, {
- error: 'noperms',
+ return res.json(403, {
+ error: 'no_perms',
reason: 'Current user can not publish this module'
});
}
- Module.get(name, 'latest', function (err, mod) {
- if (err) {
- return next(err);
+ var ep = eventproxy.create();
+ ep.fail(next);
+
+ Module.getLatest(name, ep.doneLater('latest'));
+ Module.get(name, 'next', ep.done(function (nextMod) {
+ if (nextMod) {
+ nextMod.exists = true;
+ return ep.emit('next', nextMod);
+ }
+ // ensure next module exits
+ // because updateLatest will create next module fail
+ nextMod = {
+ name: name,
+ version: 'next',
+ author: username,
+ package: {
+ name: name,
+ version: 'next',
+ description: pkg.description,
+ readme: pkg.readme,
+ maintainers: pkg.maintainers,
+ },
+ };
+ Module.add(nextMod, ep.done(function (result) {
+ nextMod.id = result.id;
+ ep.emit('next', nextMod);
+ }));
+ }));
+
+ ep.all('latest', 'next', function (latestMod, nextMod) {
+ var maintainers = latestMod ? latestMod.package.maintainers : nextMod.package.maintainers;
+ var match = maintainers.filter(function (item) {
+ return item.name === username;
+ });
+
+ if (match.length === 0) {
+ return res.json(403, {
+ error: 'no_perms',
+ reason: 'Current user can not publish this module'
+ });
}
- if (mod) {
- match = mod.package.maintainers.filter(function (item) {
- return item.name === username;
- });
- if (match.length === 0) {
- return res.json(401, {
- error: 'noperms',
- reason: 'Current user can not publish this module'
- });
- }
-
+ if (latestMod || nextMod.exists) {
return res.json(409, {
error: 'conflict',
reason: 'Document update conflict.'
});
}
- mod = {
- name: name,
- version: 'latest',
- author: username,
- package: {
- name: name,
- version: 'init',
- description: pkg.description,
- readme: pkg.readme,
- maintainers: pkg.maintainers,
- author: {
- name: username,
- email: req.session.email,
- }
- },
- };
- Module.add(mod, function (err, result) {
- if (err) {
- return next(err);
- }
- res.json(201, {
- ok: true,
- id: name,
- rev: String(result.id),
- });
+ res.json(201, {
+ ok: true,
+ id: name,
+ rev: String(nextMod.id),
});
});
};
diff --git a/logo.png b/logo.png
new file mode 100644
index 0000000..d20debf
Binary files /dev/null and b/logo.png differ
diff --git a/package.json b/package.json
index 966913c..cc926a3 100644
--- a/package.json
+++ b/package.json
@@ -20,19 +20,19 @@
"debug": "0.7.4",
"utility": "0.1.8",
"ready": "0.1.1",
- "connect": "~2.11.0",
- "connect-rt": "~0.0.2",
- "connect-redis": "~1.4.6",
- "urlrouter": "~0.5.3",
- "graceful": "~0.0.5",
- "moment": "~2.4.0",
- "logfilestream": "~0.1.0",
- "ms": "~0.6.1",
- "mkdirp": "~0.3.5",
+ "connect": "2.11.2",
+ "connect-rt": "0.0.2",
+ "connect-redis": "1.4.6",
+ "urlrouter": "0.5.3",
+ "graceful": "0.0.5",
+ "moment": "2.4.0",
+ "logfilestream": "0.1.0",
+ "ms": "0.6.1",
+ "mkdirp": "0.3.5",
"mysql": "2.0.0-rc1",
- "response-patch": "~0.1.1",
- "response-cookie": "~0.0.2",
- "eventproxy": "~0.2.6"
+ "response-patch": "0.1.1",
+ "response-cookie": "0.0.2",
+ "eventproxy": "0.2.6"
},
"devDependencies": {
"supertest": "*",
diff --git a/proxy/module.js b/proxy/module.js
index 5241caa..f5e8e1d 100644
--- a/proxy/module.js
+++ b/proxy/module.js
@@ -101,7 +101,7 @@ exports.get = function (name, version, callback) {
});
};
-var SELECT_LATEST_MODULE_SQL = 'SELECT ' + MODULE_COLUMNS + ' FROM module WHERE name=? ORDER BY id DESC LIMIT 1;';
+var SELECT_LATEST_MODULE_SQL = 'SELECT ' + MODULE_COLUMNS + ' FROM module WHERE name=? AND version <> "next" ORDER BY id DESC LIMIT 1;';
exports.getLatest = function (name, callback) {
mysql.queryOne(SELECT_LATEST_MODULE_SQL, [name], function (err, row) {
@@ -138,3 +138,9 @@ exports.listByName = function (name, callback) {
callback(err, rows);
});
};
+
+var DELETE_MODULE_BY_NAME_SQL = 'DELETE FROM module WHERE name=?;';
+exports.removeByName = function (name, callback) {
+ mysql.query(DELETE_MODULE_BY_NAME_SQL, [name], callback);
+};
+
diff --git a/routes/registry.js b/routes/registry.js
index 858debd..20e7894 100644
--- a/routes/registry.js
+++ b/routes/registry.js
@@ -27,12 +27,13 @@ function routes(app) {
// module
app.get('/:name', mod.show);
+ // try to add module
app.put('/:name', login, mod.add);
// put tarball
// https://registry.npmjs.org/cnpmjs.org/-/cnpmjs.org-0.0.0.tgz/-rev/1-c85bc65e8d2470cc4d82b8f40da65b8e
app.put('/:name/-/:filename/-rev/:rev', login, mod.upload);
- // tag
+ // put package.json to module
app.put('/:name/:version/-tag/latest', login, mod.updateLatest);
// try to create a new user
diff --git a/servers/registry.js b/servers/registry.js
index 647343a..7d136bd 100644
--- a/servers/registry.js
+++ b/servers/registry.js
@@ -50,6 +50,10 @@ app.use(auth());
app.use(urlrouter(routes));
+app.use(function (req, res, next) {
+ res.json(404, {error: 'not_found', reason: 'document not found'});
+});
+
/**
* Error handler
*/
diff --git a/test/controllers/registry/module.test.js b/test/controllers/registry/module.test.js
index 9b94156..63d6cd6 100644
--- a/test/controllers/registry/module.test.js
+++ b/test/controllers/registry/module.test.js
@@ -14,9 +14,14 @@
* Module dependencies.
*/
+var fs = require('fs');
+var path = require('path');
var should = require('should');
var request = require('supertest');
var app = require('../../../servers/registry');
+var Module = require('../../../proxy/module');
+
+var fixtures = path.join(path.dirname(path.dirname(__dirname)), 'fixtures');
describe('controllers/registry/module.test.js', function () {
before(function (done) {
@@ -45,4 +50,213 @@ describe('controllers/registry/module.test.js', function () {
});
});
});
+
+ describe('PUT /:name', function () {
+ var pkg = {
+ name: 'testputmodule',
+ description: 'test put module',
+ readme: 'readme text',
+ maintainers: [{
+ name: 'cnpmjstest10',
+ email: 'cnpmjstest10@cnpmjs.org'
+ }],
+ };
+ var baseauth = 'Basic ' + new Buffer('cnpmjstest10:cnpmjstest10').toString('base64');
+ var baseauthOther = 'Basic ' + new Buffer('cnpmjstest101:cnpmjstest101').toString('base64');
+ var lastRev;
+
+ before(function (done) {
+ // clean up testputmodule
+ Module.removeByName('testputmodule', done);
+ });
+
+ it('should try to add not exists module return 201', function (done) {
+ request(app)
+ .put('/' + pkg.name)
+ .set('authorization', baseauth)
+ .send(pkg)
+ .expect(201, function (err, res) {
+ should.not.exist(err);
+ res.body.should.have.keys('ok', 'id', 'rev');
+ res.body.ok.should.equal(true);
+ res.body.id.should.equal(pkg.name);
+ res.body.rev.should.be.a.String;
+ done();
+ });
+ });
+
+ it('should try to add return 409 when only next module exists', function (done) {
+ request(app)
+ .put('/' + pkg.name)
+ .set('authorization', baseauth)
+ .send(pkg)
+ .expect(409, function (err, res) {
+ should.not.exist(err);
+ res.body.should.eql({
+ error: 'conflict',
+ reason: 'Document update conflict.'
+ });
+ done();
+ });
+ });
+
+ it('should try to add return 403 when not module user and only next module exists', function (done) {
+ request(app)
+ .put('/' + pkg.name)
+ .set('authorization', baseauthOther)
+ .send(pkg)
+ .expect(403, function (err, res) {
+ should.not.exist(err);
+ res.body.should.eql({
+ error: 'no_perms',
+ reason: 'Current user can not publish this module'
+ });
+ done();
+ });
+ });
+
+ it('should get versions empty when only next module exists', function (done) {
+ request(app)
+ .get('/' + pkg.name)
+ .expect(200, function (err, res) {
+ should.not.exist(err);
+ res.body.should.have.keys('_id', '_rev', 'name', 'description', 'versions', 'dist-tags',
+ 'readme', 'maintainers', 'time', '_attachments');
+ res.body.versions.should.eql({});
+ res.body.time.should.eql({});
+ res.body['dist-tags'].should.eql({});
+ lastRev = res.body._rev;
+ console.log('lastRev: %s', lastRev);
+ done();
+ });
+ });
+
+ it('should upload tarball success: /:name/-/:filename/-rev/:rev', function (done) {
+ var body = fs.readFileSync(path.join(fixtures, 'testputmodule-0.1.9.tgz'));
+ request(app)
+ .put('/' + pkg.name + '/-/' + pkg.name + '-0.1.9.tgz/-rev/' + lastRev)
+ .set('authorization', baseauth)
+ .set('content-type', 'application/octet-stream')
+ .set('content-length', '' + body.length)
+ .send(body)
+ .expect(201, function (err, res) {
+ should.not.exist(err);
+ res.body.should.eql({
+ ok: true,
+ rev: lastRev,
+ });
+ done();
+ });
+ });
+
+ it('should upload tarball success again: /:name/-/:filename/-rev/:rev', function (done) {
+ var body = fs.readFileSync(path.join(fixtures, 'testputmodule-0.1.9.tgz'));
+ request(app)
+ .put('/' + pkg.name + '/-/' + pkg.name + '-0.1.9.tgz/-rev/' + lastRev)
+ .set('authorization', baseauth)
+ .set('content-type', 'application/octet-stream')
+ .set('content-length', '' + body.length)
+ .send(body)
+ .expect(201, function (err, res) {
+ should.not.exist(err);
+ res.body.should.eql({
+ ok: true,
+ rev: lastRev,
+ });
+ done();
+ });
+ });
+
+ // it('should upload tarball fail 403 when header size not match body size', function (done) {
+ // var body = fs.readFileSync(path.join(fixtures, 'testputmodule-0.1.9.tgz'));
+ // request(app)
+ // .put('/' + pkg.name + '/-/' + pkg.name + '-0.1.9.tgz/-rev/' + lastRev)
+ // .set('authorization', baseauth)
+ // .set('content-type', 'application/octet-stream')
+ // .set('content-length', '' + (body.length + 1))
+ // .send(body)
+ // .expect(404, function (err, res) {
+ // should.not.exist(err);
+ // res.body.should.eql({
+ // error: 'size_wrong',
+ // reason: 'document not found'
+ // });
+ // done();
+ // });
+ // });
+
+ it('should upload tarball fail 403 when rev not match current module', function (done) {
+ var body = fs.readFileSync(path.join(fixtures, 'testputmodule-0.1.9.tgz'));
+ request(app)
+ .put('/' + pkg.name + '/-/' + pkg.name + '-0.1.9.tgz/-rev/25')
+ .set('authorization', baseauth)
+ .set('content-type', 'application/octet-stream')
+ .set('content-length', '' + body.length)
+ .send(body)
+ .expect(403, function (err, res) {
+ should.not.exist(err);
+ res.body.should.eql({
+ error: 'no_perms',
+ reason: 'Current user can not publish this module'
+ });
+ done();
+ });
+ });
+
+ it('should upload tarball fail 404 when rev wrong', function (done) {
+ var body = fs.readFileSync(path.join(fixtures, 'testputmodule-0.1.9.tgz'));
+ request(app)
+ .put('/' + pkg.name + '/-/' + pkg.name + '-0.1.9.tgz/-rev/' + lastRev + '1')
+ .set('authorization', baseauth)
+ .set('content-type', 'application/octet-stream')
+ .set('content-length', '' + body.length)
+ .send(body)
+ .expect(404, function (err, res) {
+ should.not.exist(err);
+ res.body.should.eql({
+ error: 'not_found',
+ reason: 'document not found'
+ });
+ done();
+ });
+ });
+
+ it('should update package.json info success: /:name/:version/-tag/latest', function (done) {
+ var pkg = require(path.join(fixtures, 'testputmodule.json')).versions['0.1.8'];
+ pkg.name = 'testputmodule';
+ pkg.version = '0.1.9';
+ request(app)
+ .put('/' + pkg.name + '/' + pkg.version + '/-tag/latest')
+ .set('authorization', baseauth)
+ .send(pkg)
+ .expect(201, function (err, res) {
+ should.not.exist(err);
+ res.body.should.eql({
+ ok: true,
+ rev: Number(lastRev) + 1
+ });
+ done();
+ });
+ });
+
+ it('should update package.json info again fail 403: /:name/:version/-tag/latest', function (done) {
+ var pkg = require(path.join(fixtures, 'testputmodule.json')).versions['0.1.8'];
+ pkg.name = 'testputmodule';
+ pkg.version = '0.1.10';
+ request(app)
+ .put('/' + pkg.name + '/' + pkg.version + '/-tag/latest')
+ .set('authorization', baseauth)
+ .send(pkg)
+ .expect(403, function (err, res) {
+ should.not.exist(err);
+ res.body.should.eql({
+ error: 'version_wrong',
+ reason: 'version not match'
+ });
+ done();
+ });
+ });
+
+
+ });
});
diff --git a/test/fixtures/testputmodule-0.1.9.tgz b/test/fixtures/testputmodule-0.1.9.tgz
new file mode 100644
index 0000000..81dcebf
Binary files /dev/null and b/test/fixtures/testputmodule-0.1.9.tgz differ
diff --git a/test/fixtures/testputmodule.json b/test/fixtures/testputmodule.json
new file mode 100644
index 0000000..5105d9c
--- /dev/null
+++ b/test/fixtures/testputmodule.json
@@ -0,0 +1 @@
+{"_id":"utility","_rev":"45-26b0aa6f80ab9465e551ed9c0a244aa1","name":"utility","description":"A collection of useful utilities.","dist-tags":{"latest":"0.1.8"},"versions":{"0.0.1":{"name":"utility","version":"0.0.1","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test"},"dependencies":{},"devDependencies":{"should":"*","jscover":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility)\n=======\n\n\n\nDescription\n\n* jscoverage: [100%](http://fengmk2.github.com/coverage/utility.html)\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('aer'); // 'd194f6194fc458544482bbb8f0b74c6b'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","readmeFilename":"README.md","_id":"utility@0.0.1","dist":{"shasum":"cdaa6bd91c808af13fde8645a166e21cdce0c55a","tarball":"http://registry.npmjs.org/utility/-/utility-0.0.1.tgz"},"_npmVersion":"1.1.65","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.0.2":{"name":"utility","version":"0.0.2","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test"},"dependencies":{},"devDependencies":{"should":"*","jscover":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility)\n=======\n\n\n\nDescription\n\n* jscoverage: [100%](http://fengmk2.github.com/coverage/utility.html)\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('aer'); // 'd194f6194fc458544482bbb8f0b74c6b'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","readmeFilename":"README.md","_id":"utility@0.0.2","dist":{"shasum":"0b1c444ec6942f4d51ec18155cf557ba6cf245e0","tarball":"http://registry.npmjs.org/utility/-/utility-0.0.2.tgz"},"_from":".","_npmVersion":"1.2.2","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.0.3":{"name":"utility","version":"0.0.3","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test"},"dependencies":{},"devDependencies":{"should":"*","jscover":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility)\n=======\n\n\n\nDescription\n\n* jscoverage: [100%](http://fengmk2.github.com/coverage/utility.html)\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","readmeFilename":"README.md","_id":"utility@0.0.3","dist":{"shasum":"cbc6b9e6271e013221fa62746e02af22c5668e11","tarball":"http://registry.npmjs.org/utility/-/utility-0.0.3.tgz"},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.0.4":{"name":"utility","version":"0.0.4","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test"},"dependencies":{},"devDependencies":{"should":"*","jscover":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility)\n=======\n\n\n\nDescription\n\n* jscoverage: [100%](http://fengmk2.github.com/coverage/utility.html)\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n```\n\n## accessLogDate() benchmark\n\n[benchmark/date_format.js](https://github.com/fengmk2/fengmk2.github.com/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js\n\nmoment().format(): \"16/Apr/2013:18:18:30 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 18:18:30 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 18:18:30 GMT+0800 (CST)\"\nfasterAccessDate(): \"16/Apr/2013:18:18:30 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:18:18:30 +0800\"\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 78,364 ops/sec ±1.01% (99 runs sampled)\nnew Date().toString() x 837,714 ops/sec ±0.92% (95 runs sampled)\nDate() x 777,068 ops/sec ±4.76% (90 runs sampled)\nfasterAccessDate() x 337,151 ops/sec ±1.51% (95 runs sampled)\nfasterAccessDate2() x 335,866 ops/sec ±2.27% (92 runs sampled)\nFastest is new Date().toString()\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","readmeFilename":"README.md","_id":"utility@0.0.4","dist":{"shasum":"352c38cc9e8ad76fe0b501f8236e543176f4cdef","tarball":"http://registry.npmjs.org/utility/-/utility-0.0.4.tgz"},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.0.5":{"name":"utility","version":"0.0.5","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test"},"dependencies":{},"devDependencies":{"should":"*","moment":"*","jscover":"*","benchmark":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities. \n\n* jscoverage: [100%](http://fengmk2.github.com/coverage/utility.html)\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js \n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js \n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","_id":"utility@0.0.5","dist":{"shasum":"bc91721967dd060cd9a2c358bac25191cfc42722","tarball":"http://registry.npmjs.org/utility/-/utility-0.0.5.tgz"},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.0.6":{"name":"utility","version":"0.0.6","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test"},"dependencies":{},"devDependencies":{"should":"*","moment":"*","jscover":"*","benchmark":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities. \n\n* jscoverage: [100%](http://fengmk2.github.com/coverage/utility.html)\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate\nutils.logDate(); // '2013-04-17 14:43:02.674'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js \n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js \n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","_id":"utility@0.0.6","dist":{"shasum":"891e023f924de7154bce8c5114c2b0f34d4e3bed","tarball":"http://registry.npmjs.org/utility/-/utility-0.0.6.tgz"},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.0.7":{"name":"utility","version":"0.0.7","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test"},"dependencies":{},"devDependencies":{"should":"*","moment":"*","jscover":"*","benchmark":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities. \n\n* jscoverage: [100%](http://fengmk2.github.com/coverage/utility.html)\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate\nutils.logDate(); // '2013-04-17 14:43:02.674'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js \n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js \n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","_id":"utility@0.0.7","dist":{"shasum":"7d4aa46b6580e50c677e7d9183e89887a63d2762","tarball":"http://registry.npmjs.org/utility/-/utility-0.0.7.tgz"},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.0.8":{"name":"utility","version":"0.0.8","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test"},"dependencies":{},"devDependencies":{"should":"*","moment":"*","jscover":"*","benchmark":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities. \n\n* jscoverage: [100%](http://fengmk2.github.com/coverage/utility.html)\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate\nutils.logDate(); // '2013-04-17 14:43:02.674'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js \n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js \n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","_id":"utility@0.0.8","dist":{"shasum":"26f9a59e554e54f92cdbbc6e854b75d75cc3279f","tarball":"http://registry.npmjs.org/utility/-/utility-0.0.8.tgz"},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.0.9":{"name":"utility","version":"0.0.9","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test"},"dependencies":{},"devDependencies":{"should":"*","moment":"*","jscover":"*","benchmark":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities. \n\n* jscoverage: [100%](http://fengmk2.github.com/coverage/utility.html)\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate\nutils.logDate(); // '2013-04-17 14:43:02.674'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js \n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js \n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary \n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors : \n 23 fengmk2 100.0%\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","_id":"utility@0.0.9","dist":{"shasum":"c14fb427dc7f4cba5e6e3f87b864b772adb38bb1","tarball":"http://registry.npmjs.org/utility/-/utility-0.0.9.tgz"},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.0.10":{"name":"utility","version":"0.0.10","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test-all","blanket":{"pattern":"utility/lib"},"travis-cov":{"threshold":99}},"dependencies":{},"devDependencies":{"should":"*","mm":"*","moment":"*","blanket":"*","travis-cov":"*","coveralls":"*","mocha-lcov-reporter":"*","benchmark":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility) [](https://coveralls.io/r/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities. \n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate\nutils.logDate(); // '2013-04-17 14:43:02.674'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n\n// get first ip\nutils.getIP(); // \"10.7.68.72\"\nutils.getIPv4(); // \"10.7.68.72\"\nutils.getIP('ppp'); // \"10.2.0.231\"\n\nutils.getIPv6(); // \"fe80::cabc:c8ff:feef:f996\"\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js \n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js \n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary \n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors : \n 23 fengmk2 100.0%\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fengmk2/utility/issues"},"_id":"utility@0.0.10","dist":{"shasum":"5517590f3ab4e9d919d40fb0350131ca3d4256da","tarball":"http://registry.npmjs.org/utility/-/utility-0.0.10.tgz"},"_from":".","_npmVersion":"1.2.30","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.0.11":{"name":"utility","version":"0.0.11","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test-all","blanket":{"pattern":"utility/lib"},"travis-cov":{"threshold":99}},"dependencies":{},"devDependencies":{"should":"*","mm":"*","moment":"*","blanket":"*","travis-cov":"*","coveralls":"*","mocha-lcov-reporter":"*","benchmark":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility) [](https://coveralls.io/r/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities. \n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate\nutils.logDate(); // '2013-04-17 14:43:02.674'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n\n// get first ip\nutils.getIP(); // \"10.7.68.72\"\nutils.getIPv4(); // \"10.7.68.72\"\nutils.getIP('ppp'); // \"10.2.0.231\"\n\nutils.getIPv6(); // \"fe80::cabc:c8ff:feef:f996\"\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js \n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js \n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary \n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors : \n 23 fengmk2 100.0%\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fengmk2/utility/issues"},"_id":"utility@0.0.11","dist":{"shasum":"5decec00e6d4e0a5f79ff091b2d8972ded25493c","tarball":"http://registry.npmjs.org/utility/-/utility-0.0.11.tgz"},"_from":".","_npmVersion":"1.2.30","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.0.12":{"name":"utility","version":"0.0.12","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test-all","blanket":{"pattern":"utility/lib"},"travis-cov":{"threshold":99}},"dependencies":{},"devDependencies":{"should":"*","mm":"*","moment":"*","blanket":"*","travis-cov":"*","coveralls":"*","mocha-lcov-reporter":"*","benchmark":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility) [](https://coveralls.io/r/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities. \n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate\nutils.logDate(); // '2013-04-17 14:43:02.674'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n\n// get first ip\nutils.getIP(); // \"10.7.68.72\"\nutils.getIPv4(); // \"10.7.68.72\"\nutils.getIP('ppp'); // \"10.2.0.231\"\n\nutils.getIPv6(); // \"fe80::cabc:c8ff:feef:f996\"\n\n// get a function parameter's names\nutils.getParamNames(function (key1, key2) {}); // ['key1', 'key2']\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js \n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js \n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary \n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors : \n 23 fengmk2 100.0%\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fengmk2/utility/issues"},"_id":"utility@0.0.12","dist":{"shasum":"b3c24f6d3517722b22d3e0b2a583ed88fb6033d2","tarball":"http://registry.npmjs.org/utility/-/utility-0.0.12.tgz"},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.0.13":{"name":"utility","version":"0.0.13","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test-all"},"dependencies":{"address":">=0.0.1"},"devDependencies":{"should":"*","mm":"*","moment":"*","blanket":"*","travis-cov":"*","coveralls":"*","mocha-lcov-reporter":"*","benchmark":"*","mocha":"*"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility) [](https://coveralls.io/r/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities. \n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate\nutils.logDate(); // '2013-04-17 14:43:02.674'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n\n// get first ip\n[WARNNING] getIP() remove, PLEASE use `https://github.com/fengmk2/address` module instead\n\n// get a function parameter's names\nutils.getParamNames(function (key1, key2) {}); // ['key1', 'key2']\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js \n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js \n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary \n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors : \n 23 fengmk2 100.0%\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fengmk2/utility/issues"},"_id":"utility@0.0.13","dist":{"shasum":"0a3a846c3151a2bb0648ffaa1fabad3da9fa01cd","tarball":"http://registry.npmjs.org/utility/-/utility-0.0.13.tgz"},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.1.0":{"name":"utility","version":"0.1.0","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test-all"},"dependencies":{"address":">=0.0.1"},"devDependencies":{"should":"*","mm":"*","moment":"*","blanket":"*","travis-cov":"*","coveralls":"*","mocha-lcov-reporter":"*","benchmark":"*","mocha":"*"},"homepage":"https://github.com/fengmk2/utility","repository":{"type":"git","url":"git://github.com/fengmk2/utility.git","web":"https://github.com/fengmk2/utility"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"http://fengmk2.github.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility) [](https://coveralls.io/r/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities. \n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate\nutils.logDate(); // '2013-04-17 14:43:02.674'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n\n// get first ip\n[WARNNING] getIP() remove, PLEASE use `https://github.com/fengmk2/address` module instead\n\n// get a function parameter's names\nutils.getParamNames(function (key1, key2) {}); // ['key1', 'key2']\n\n// Unix's timestamp\nutils.timestamp(); // 1378153226\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js \n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js \n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary \n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors : \n 23 fengmk2 100.0%\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fengmk2/utility/issues"},"_id":"utility@0.1.0","dist":{"shasum":"8158ab59ab7f4f9d1ec8463b7353c1957dd1b52b","tarball":"http://registry.npmjs.org/utility/-/utility-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.1.1":{"name":"utility","version":"0.1.1","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test-all"},"dependencies":{"address":">=0.0.1"},"devDependencies":{"should":"*","mm":"*","moment":"*","blanket":"*","travis-cov":"*","coveralls":"*","mocha-lcov-reporter":"*","benchmark":"*","mocha":"*"},"homepage":"https://github.com/fengmk2/utility","repository":{"type":"git","url":"git://github.com/fengmk2/utility.git","web":"https://github.com/fengmk2/utility"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"http://fengmk2.github.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility) [](https://coveralls.io/r/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities. \n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n// md5 hase output base64\nutils.md5('è‹åƒ', 'base64'); // 'X3M8R8WKB31hJXECstREgQ=='\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate\nutils.logDate(); // '2013-04-17 14:43:02.674'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n\n// get first ip\n[WARNNING] getIP() remove, PLEASE use `https://github.com/fengmk2/address` module instead\n\n// get a function parameter's names\nutils.getParamNames(function (key1, key2) {}); // ['key1', 'key2']\n\n// Unix's timestamp\nutils.timestamp(); // 1378153226\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js \n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js \n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary \n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors : \n 23 fengmk2 100.0%\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fengmk2/utility/issues"},"_id":"utility@0.1.1","dist":{"shasum":"7d7d9441d0689b3ddba8a3b99db48399c79aba2f","tarball":"http://registry.npmjs.org/utility/-/utility-0.1.1.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.1.2":{"name":"utility","version":"0.1.2","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test-all"},"dependencies":{"address":">=0.0.1"},"devDependencies":{"should":"*","mm":"*","moment":"*","blanket":"*","travis-cov":"*","coveralls":"*","mocha-lcov-reporter":"*","benchmark":"*","mocha":"*"},"homepage":"https://github.com/fengmk2/utility","repository":{"type":"git","url":"git://github.com/fengmk2/utility.git","web":"https://github.com/fengmk2/utility"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"http://fengmk2.github.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility) [](https://coveralls.io/r/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities. \n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n// md5 hase output base64\nutils.md5('è‹åƒ', 'base64'); // 'X3M8R8WKB31hJXECstREgQ=='\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n\n// get first ip\n[WARNNING] getIP() remove, PLEASE use `https://github.com/fengmk2/address` module instead\n\n// get a function parameter's names\nutils.getParamNames(function (key1, key2) {}); // ['key1', 'key2']\n```\n\n### Date utils\n\n```js\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate, \n// 'YYYY-MM-DD HH:mm:ss.SSS' format date string\nutils.logDate(); // '2013-04-17 14:43:02.674'\nutils.YYYYMMDDHHmmssSSS(); // '2013-04-17 14:43:02.674'\n\n// 'YYYY-MM-DD HH:mm:ss' format date string\nutils.YYYYMMDDHHmmss(); // '2013-04-17 14:43:02'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Unix's timestamp\nutils.timestamp(); // 1378153226\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js \n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js \n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary \n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors : \n 23 fengmk2 100.0%\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fengmk2/utility/issues"},"_id":"utility@0.1.2","dist":{"shasum":"6391f6ee3a2e3863a356390372e06d027cb3741f","tarball":"http://registry.npmjs.org/utility/-/utility-0.1.2.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.1.3":{"name":"utility","version":"0.1.3","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test-all"},"dependencies":{"address":">=0.0.1"},"devDependencies":{"should":"*","mm":"*","moment":"*","blanket":"*","travis-cov":"*","coveralls":"*","mocha-lcov-reporter":"*","benchmark":"*","mocha":"*"},"homepage":"https://github.com/fengmk2/utility","repository":{"type":"git","url":"git://github.com/fengmk2/utility.git","web":"https://github.com/fengmk2/utility"},"keywords":["utility"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"http://fengmk2.github.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility) [](https://coveralls.io/r/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities. \n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n// md5 hase output base64\nutils.md5('è‹åƒ', 'base64'); // 'X3M8R8WKB31hJXECstREgQ=='\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n\n// get first ip\n[WARNNING] getIP() remove, PLEASE use `https://github.com/fengmk2/address` module instead\n\n// get a function parameter's names\nutils.getParamNames(function (key1, key2) {}); // ['key1', 'key2']\n```\n\n### Date utils\n\n```js\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate, \n// 'YYYY-MM-DD HH:mm:ss.SSS' format date string\nutils.logDate(); // '2013-04-17 14:43:02.674'\nutils.YYYYMMDDHHmmssSSS(); // '2013-04-17 14:43:02.674'\n\n// 'YYYY-MM-DD HH:mm:ss' format date string\nutils.YYYYMMDDHHmmss(); // '2013-04-17 14:43:02'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Unix's timestamp\nutils.timestamp(); // 1378153226\n```\n\n### Number utils\n\n```js\n// Detect a number string can safe convert to Javascript Number.: `-9007199254740991 ~ 9007199254740991`\nutils.isSafeNumberString('9007199254740991'); // true\nutils.isSafeNumberString('9007199254740993'); // false\n\n// Convert string to number safe:\nutils.toSafeNumber('9007199254740991'); // 9007199254740991\nutils.toSafeNumber('9007199254740993'); // '9007199254740993'\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js \n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js \n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary \n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors : \n 23 fengmk2 100.0%\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fengmk2/utility/issues"},"_id":"utility@0.1.3","dist":{"shasum":"b5036f755d926bc5c261741cd4269c1f311c68c5","tarball":"http://registry.npmjs.org/utility/-/utility-0.1.3.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.1.4":{"name":"utility","version":"0.1.4","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test-all"},"dependencies":{"address":">=0.0.1"},"devDependencies":{"should":"*","mm":"*","moment":"*","blanket":"*","travis-cov":"*","coveralls":"*","mocha-lcov-reporter":"*","benchmark":"*","mocha":"*"},"homepage":"https://github.com/fengmk2/utility","repository":{"type":"git","url":"git://github.com/fengmk2/utility.git","web":"https://github.com/fengmk2/utility"},"keywords":["utility"],"engines":{"node":">= 0.8.0"},"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"http://fengmk2.github.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility) [](https://coveralls.io/r/fengmk2/utility)\n=======\n\n\n\nA collection of useful utilities.\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n// md5 hase output base64\nutils.md5('è‹åƒ', 'base64'); // 'X3M8R8WKB31hJXECstREgQ=='\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n\n// get first ip\n[WARNNING] getIP() remove, PLEASE use `https://github.com/fengmk2/address` module instead\n\n// get a function parameter's names\nutils.getParamNames(function (key1, key2) {}); // ['key1', 'key2']\n```\n\n### Date utils\n\n```js\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate,\n// 'YYYY-MM-DD HH:mm:ss.SSS' format date string\nutils.logDate(); // '2013-04-17 14:43:02.674'\nutils.YYYYMMDDHHmmssSSS(); // '2013-04-17 14:43:02.674'\n\n// 'YYYY-MM-DD HH:mm:ss' format date string\nutils.YYYYMMDDHHmmss(); // '2013-04-17 14:43:02'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Unix's timestamp\nutils.timestamp(); // 1378153226\n```\n\n### Number utils\n\n```js\n// Detect a number string can safe convert to Javascript Number.: `-9007199254740991 ~ 9007199254740991`\nutils.isSafeNumberString('9007199254740991'); // true\nutils.isSafeNumberString('9007199254740993'); // false\n\n// Convert string to number safe:\nutils.toSafeNumber('9007199254740991'); // 9007199254740991\nutils.toSafeNumber('9007199254740993'); // '9007199254740993'\n```\n\n### Timers\n\n```js\nutils.setImmediate(function () {\n console.log('hi');\n});\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js\n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js\n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary\n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors :\n 23 fengmk2 100.0%\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fengmk2/utility/issues"},"_id":"utility@0.1.4","dist":{"shasum":"ab97cdd26fd92e9da71128da8af06c7d24057ff2","tarball":"http://registry.npmjs.org/utility/-/utility-0.1.4.tgz"},"_from":".","_npmVersion":"1.3.13","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.1.5":{"name":"utility","version":"0.1.5","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test-all"},"dependencies":{"address":">=0.0.1"},"devDependencies":{"should":"*","mm":"*","moment":"*","blanket":"*","travis-cov":"*","coveralls":"*","mocha-lcov-reporter":"*","benchmark":"*","mocha":"*"},"homepage":"https://github.com/fengmk2/utility","repository":{"type":"git","url":"git://github.com/fengmk2/utility.git","web":"https://github.com/fengmk2/utility"},"keywords":["utility"],"engines":{"node":">= 0.8.0"},"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"http://fengmk2.github.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility) [](https://coveralls.io/r/fengmk2/utility)\n=======\n\n[](https://nodei.co/npm/utility)\n\n\n\nA collection of useful utilities.\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n// md5 hase output base64\nutils.md5('è‹åƒ', 'base64'); // 'X3M8R8WKB31hJXECstREgQ=='\n\n// Object md5 hash\nutils.md5({foo: 'bar', bar: 'foo'}).should.equal(utils.md5({bar: 'foo', foo: 'bar'}));\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n\n// get first ip\n[WARNNING] getIP() remove, PLEASE use `https://github.com/fengmk2/address` module instead\n\n// get a function parameter's names\nutils.getParamNames(function (key1, key2) {}); // ['key1', 'key2']\n```\n\n### Date utils\n\n```js\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate,\n// 'YYYY-MM-DD HH:mm:ss.SSS' format date string\nutils.logDate(); // '2013-04-17 14:43:02.674'\nutils.YYYYMMDDHHmmssSSS(); // '2013-04-17 14:43:02.674'\n\n// 'YYYY-MM-DD HH:mm:ss' format date string\nutils.YYYYMMDDHHmmss(); // '2013-04-17 14:43:02'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Unix's timestamp\nutils.timestamp(); // 1378153226\n```\n\n### Number utils\n\n```js\n// Detect a number string can safe convert to Javascript Number.: `-9007199254740991 ~ 9007199254740991`\nutils.isSafeNumberString('9007199254740991'); // true\nutils.isSafeNumberString('9007199254740993'); // false\n\n// Convert string to number safe:\nutils.toSafeNumber('9007199254740991'); // 9007199254740991\nutils.toSafeNumber('9007199254740993'); // '9007199254740993'\n```\n\n### Timers\n\n```js\nutils.setImmediate(function () {\n console.log('hi');\n});\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js\n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js\n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary\n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors :\n 23 fengmk2 100.0%\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fengmk2/utility/issues"},"_id":"utility@0.1.5","dist":{"shasum":"713479560cd1e27ed1cbf3a8503939811ac2e380","tarball":"http://registry.npmjs.org/utility/-/utility-0.1.5.tgz"},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.1.6":{"name":"utility","version":"0.1.6","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test-all"},"dependencies":{"address":">=0.0.1"},"devDependencies":{"should":"*","mm":"*","moment":"*","blanket":"*","travis-cov":"*","coveralls":"*","mocha-lcov-reporter":"*","benchmark":"*","mocha":"*"},"homepage":"https://github.com/fengmk2/utility","repository":{"type":"git","url":"git://github.com/fengmk2/utility.git","web":"https://github.com/fengmk2/utility"},"keywords":["utility"],"engines":{"node":">= 0.8.0"},"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"http://fengmk2.github.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility) [](https://coveralls.io/r/fengmk2/utility)\n=======\n\n[](https://nodei.co/npm/utility)\n\n\n\nA collection of useful utilities.\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n// md5 hase output base64\nutils.md5('è‹åƒ', 'base64'); // 'X3M8R8WKB31hJXECstREgQ=='\n\n// Object md5 hash\nutils.md5({foo: 'bar', bar: 'foo'}).should.equal(utils.md5({bar: 'foo', foo: 'bar'}));\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n\n// get first ip\n[WARNNING] getIP() remove, PLEASE use `https://github.com/fengmk2/address` module instead\n\n// get a function parameter's names\nutils.getParamNames(function (key1, key2) {}); // ['key1', 'key2']\n```\n\n### Date utils\n\n```js\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate,\n// 'YYYY-MM-DD HH:mm:ss.SSS' format date string\nutils.logDate(); // '2013-04-17 14:43:02.674'\nutils.YYYYMMDDHHmmssSSS(); // '2013-04-17 14:43:02.674'\n\n// 'YYYY-MM-DD HH:mm:ss' format date string\nutils.YYYYMMDDHHmmss(); // '2013-04-17 14:43:02'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Unix's timestamp\nutils.timestamp(); // 1378153226\n\n// Parse timestamp\n// seconds\nutils.timestamp(1385091596); // Fri Nov 22 2013 11:39:56 GMT+0800 (CST)\n// millseconds\nutils.timestamp(1385091596000); // Fri Nov 22 2013 11:39:56 GMT+0800 (CST)\n```\n\n### Number utils\n\n```js\n// Detect a number string can safe convert to Javascript Number.: `-9007199254740991 ~ 9007199254740991`\nutils.isSafeNumberString('9007199254740991'); // true\nutils.isSafeNumberString('9007199254740993'); // false\n\n// Convert string to number safe:\nutils.toSafeNumber('9007199254740991'); // 9007199254740991\nutils.toSafeNumber('9007199254740993'); // '9007199254740993'\n```\n\n### Timers\n\n```js\nutils.setImmediate(function () {\n console.log('hi');\n});\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js\n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js\n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary\n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors :\n 23 fengmk2 100.0%\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fengmk2/utility/issues"},"_id":"utility@0.1.6","dist":{"shasum":"eed05bf353a3963265c0eef0f666f45a60a56ad3","tarball":"http://registry.npmjs.org/utility/-/utility-0.1.6.tgz"},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.1.7":{"name":"utility","version":"0.1.7","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test-all"},"dependencies":{"address":">=0.0.1"},"devDependencies":{"should":"*","mm":"*","moment":"*","blanket":"*","travis-cov":"*","coveralls":"*","mocha-lcov-reporter":"*","benchmark":"*","mocha":"*"},"homepage":"https://github.com/fengmk2/utility","repository":{"type":"git","url":"git://github.com/fengmk2/utility.git","web":"https://github.com/fengmk2/utility"},"keywords":["utility"],"engines":{"node":">= 0.8.0"},"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"http://fengmk2.github.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility) [](https://coveralls.io/r/fengmk2/utility)\n=======\n\n[](https://nodei.co/npm/utility)\n\n\n\nA collection of useful utilities.\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n// md5 hase output base64\nutils.md5('è‹åƒ', 'base64'); // 'X3M8R8WKB31hJXECstREgQ=='\n\n// Object md5 hash\nutils.md5({foo: 'bar', bar: 'foo'}).should.equal(utils.md5({bar: 'foo', foo: 'bar'}));\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n\n// get first ip\n[WARNNING] getIP() remove, PLEASE use `https://github.com/fengmk2/address` module instead\n\n// get a function parameter's names\nutils.getParamNames(function (key1, key2) {}); // ['key1', 'key2']\n```\n\n### Date utils\n\n```js\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate,\n// 'YYYY-MM-DD HH:mm:ss.SSS' format date string\nutils.logDate(); // '2013-04-17 14:43:02.674'\nutils.YYYYMMDDHHmmssSSS(); // '2013-04-17 14:43:02.674'\n\n// 'YYYY-MM-DD HH:mm:ss' format date string\nutils.YYYYMMDDHHmmss(); // '2013-04-17 14:43:02'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Unix's timestamp\nutils.timestamp(); // 1378153226\n\n// Parse timestamp\n// seconds\nutils.timestamp(1385091596); // Fri Nov 22 2013 11:39:56 GMT+0800 (CST)\n// millseconds\nutils.timestamp(1385091596000); // Fri Nov 22 2013 11:39:56 GMT+0800 (CST)\n```\n\n### Number utils\n\n```js\n// Detect a number string can safe convert to Javascript Number.: `-9007199254740991 ~ 9007199254740991`\nutils.isSafeNumberString('9007199254740991'); // true\nutils.isSafeNumberString('9007199254740993'); // false\n\n// Convert string to number safe:\nutils.toSafeNumber('9007199254740991'); // 9007199254740991\nutils.toSafeNumber('9007199254740993'); // '9007199254740993'\n```\n\n### Timers\n\n```js\nutils.setImmediate(function () {\n console.log('hi');\n});\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js\n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js\n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary\n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors :\n 23 fengmk2 100.0%\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fengmk2/utility/issues"},"_id":"utility@0.1.7","dist":{"shasum":"ff5c6496151759efc4fd6ce77bb4f7c183b218dd","tarball":"http://registry.npmjs.org/utility/-/utility-0.1.7.tgz"},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}},"0.1.8":{"name":"utility","version":"0.1.8","description":"A collection of useful utilities.","main":"index.js","scripts":{"test":"make test-all"},"dependencies":{"address":">=0.0.1"},"devDependencies":{"should":"*","mm":"*","moment":"*","blanket":"*","travis-cov":"*","coveralls":"*","mocha-lcov-reporter":"*","benchmark":"*","mocha":"*"},"homepage":"https://github.com/fengmk2/utility","repository":{"type":"git","url":"git://github.com/fengmk2/utility.git","web":"https://github.com/fengmk2/utility"},"keywords":["utility"],"engines":{"node":">= 0.8.0"},"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"http://fengmk2.github.com"},"license":"MIT","readme":"utility [](http://travis-ci.org/fengmk2/utility) [](https://coveralls.io/r/fengmk2/utility)\n=======\n\n[](https://nodei.co/npm/utility)\n\n\n\nA collection of useful utilities.\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('@Pythonå‘烧å‹'); // '1369e7668bc600f0d90c06f5e395d7a9'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n// md5 hase output base64\nutils.md5('è‹åƒ', 'base64'); // 'X3M8R8WKB31hJXECstREgQ=='\n\n// Object md5 hash\nutils.md5({foo: 'bar', bar: 'foo'}).should.equal(utils.md5({bar: 'foo', foo: 'bar'}));\n\n// hmac\n// hmac-sha1 with base64 output encoding\nutils.hmac('sha1', 'I am a key', 'hello world'); // 'pO6J0LKDxRRkvSECSEdxwKx84L0='\n\n// base64 encode\nutils.base64encode('ä½ å¥½ï¿¥'); // '5L2g5aW977+l'\nutils.base64decode('5L2g5aW977+l') // 'ä½ å¥½ï¿¥'\n\n// urlsafe base64 encode\nutils.base64encode('ä½ å¥½ï¿¥', true); // '5L2g5aW977-l'\nutils.base64decode('5L2g5aW977-l', true); // 'ä½ å¥½ï¿¥'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n\n// html escape\nutils.escape('\"& &'); // '<script/>"& &'\n\n// Safe encodeURIComponent and decodeURIComponent\nutils.decodeURIComponent(utils.encodeURIComponent('ä½ å¥½, nodejs')).should.equal('ä½ å¥½, nodejs');\n\n// get first ip\n[WARNNING] getIP() remove, PLEASE use `https://github.com/fengmk2/address` module instead\n\n// get a function parameter's names\nutils.getParamNames(function (key1, key2) {}); // ['key1', 'key2']\n```\n\n### Date utils\n\n```js\n// accessLogDate\nutils.accessLogDate(); // '16/Apr/2013:16:40:09 +0800'\n\n// logDate,\n// 'YYYY-MM-DD HH:mm:ss.SSS' format date string\nutils.logDate(); // '2013-04-17 14:43:02.674'\nutils.YYYYMMDDHHmmssSSS(); // '2013-04-17 14:43:02.674'\n\n// 'YYYY-MM-DD HH:mm:ss' format date string\nutils.YYYYMMDDHHmmss(); // '2013-04-17 14:43:02'\n\n// datestruct\nutils.datestruct(); // { YYYYMMDD: 20130416, H: 8 }\n\n// Unix's timestamp\nutils.timestamp(); // 1378153226\n\n// Parse timestamp\n// seconds\nutils.timestamp(1385091596); // Fri Nov 22 2013 11:39:56 GMT+0800 (CST)\n// millseconds\nutils.timestamp(1385091596000); // Fri Nov 22 2013 11:39:56 GMT+0800 (CST)\n```\n\n### Number utils\n\n```js\n// Detect a number string can safe convert to Javascript Number.: `-9007199254740991 ~ 9007199254740991`\nutils.isSafeNumberString('9007199254740991'); // true\nutils.isSafeNumberString('9007199254740993'); // false\n\n// Convert string to number safe:\nutils.toSafeNumber('9007199254740991'); // 9007199254740991\nutils.toSafeNumber('9007199254740993'); // '9007199254740993'\n```\n\n### Timers\n\n```js\nutils.setImmediate(function () {\n console.log('hi');\n});\n```\n\n## benchmark\n\n* [jsperf: access log date format](http://jsperf.com/access-log-date-format)\n* [benchmark/date_format.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_format.js)\n\n```bash\n$ node benchmark/date_format.js\n\nmoment().format(\"DD/MMM/YYYY:HH:mm:ss ZZ\"): \"16/Apr/2013:21:12:32 +0800\"\nutils.accessLogDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate(): \"16/Apr/2013:21:12:32 +0800\"\nfasterAccessDate2(): \"16/Apr/2013:21:12:32 +0800\"\nnew Date().toString(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate(): \"Tue Apr 16 2013 21:12:32 GMT+0800 (CST)\"\nDate.now(): 1366117952162\n------------------------\nmoment().format('DD/MMM/YYYY:HH:mm:ss ZZ') x 68,300 ops/sec ±5.05% (91 runs sampled)\nutils.accessLogDate() x 1,341,341 ops/sec ±2.72% (90 runs sampled)\nfasterAccessDate() x 357,833 ops/sec ±1.32% (98 runs sampled)\nfasterAccessDate2() x 301,607 ops/sec ±5.03% (83 runs sampled)\nnew Date().toString() x 738,499 ops/sec ±3.54% (86 runs sampled)\nDate() x 794,724 ops/sec ±2.77% (95 runs sampled)\nDate.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)\nFastest is Date.now()\n```\n\n[benchmark/date_YYYYMMDD.js](https://github.com/fengmk2/utility/blob/master/benchmark/date_YYYYMMDD.js)\n\n```bash\n$ node benchmark/date_YYYYMMDD.js\n\nparseInt(moment().format(\"YYYYMMDD\"), 10): 20130416\nutils.datestruct().YYYYMMDD: 20130416\nnew Date().toString(): \"Tue Apr 16 2013 21:12:02 GMT+0800 (CST)\"\n------------------------\nparseInt(moment().format('YYYYMMDD'), 10) x 129,604 ops/sec ±0.46% (101 runs sampled)\nutils.datestruct().YYYYMMDD x 2,317,461 ops/sec ±1.38% (95 runs sampled)\nnew Date().toString() x 816,731 ops/sec ±3.46% (93 runs sampled)\nFastest is utils.datestruct().YYYYMMDD\n\n```\n\n## Authors\n\n```bash\n$ git summary\n\n project : utility\n repo age : 6 months\n active : 8 days\n commits : 23\n files : 14\n authors :\n 23 fengmk2 100.0%\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2012 - 2013 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/fengmk2/utility/issues"},"_id":"utility@0.1.8","dist":{"shasum":"7858df98a4a6eb6d8fa0a387bf5d1d262b4bedbf","tarball":"http://registry.npmjs.org/utility/-/utility-0.1.8.tgz"},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"directories":{}}},"readme":"utility [](http://travis-ci.org/fengmk2/utility)\n=======\n\n\n\nDescription\n\n* jscoverage: [100%](http://fengmk2.github.com/coverage/utility.html)\n\n## Install\n\n```bash\n$ npm install utility\n```\n\n## Usage\n\n```js\nvar utils = require('utility');\n\n// md5 hash\nutils.md5('aer'); // 'd194f6194fc458544482bbb8f0b74c6b'\nutils.md5(new Buffer('')); // 'd41d8cd98f00b204e9800998ecf8427e'\n\n// empty function\nprocess.nextTick(utils.noop);\nfunction foo(callback) {\n callback = callback || utils.noop;\n}\n```\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2012 fengmk2 <fengmk2@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"time":{"0.0.1":"2012-11-12T16:48:27.004Z","0.0.2":"2013-01-31T10:23:27.885Z","0.0.3":"2013-03-06T05:29:08.004Z","0.0.4":"2013-04-16T10:26:19.468Z","0.0.5":"2013-04-16T13:22:06.317Z","0.0.6":"2013-04-17T06:46:37.588Z","0.0.7":"2013-04-17T06:55:04.967Z","0.0.8":"2013-05-06T10:10:31.515Z","0.0.9":"2013-05-08T07:07:18.932Z","0.0.10":"2013-06-25T03:51:43.993Z","0.0.11":"2013-06-25T04:36:13.238Z","0.0.12":"2013-06-27T07:16:48.336Z","0.0.13":"2013-07-31T10:03:04.704Z","0.1.0":"2013-09-02T20:33:57.591Z","0.1.1":"2013-09-23T15:04:57.384Z","0.1.2":"2013-10-07T09:21:16.172Z","0.1.3":"2013-10-23T08:14:48.613Z","0.1.4":"2013-11-16T07:40:23.583Z","0.1.5":"2013-11-23T05:56:09.549Z","0.1.6":"2013-11-23T08:01:25.138Z","0.1.7":"2013-11-23T08:19:56.981Z","0.1.8":"2013-11-25T06:54:34.084Z"},"author":{"name":"fengmk2","email":"fengmk2@gmail.com","url":"http://fengmk2.github.com"},"repository":{"type":"git","url":"git://github.com/fengmk2/utility.git","web":"https://github.com/fengmk2/utility"},"_attachments":{"utility-0.1.8.tgz":{"content_type":"application/octet-stream","revpos":44,"digest":"md5-dkGcEqY9FHNySTD15YdvkQ==","length":7451,"stub":true},"utility-0.1.7.tgz":{"content_type":"application/octet-stream","revpos":42,"digest":"md5-IsN1VGoyy3iPJ7Q8I2OApw==","length":7407,"stub":true},"utility-0.1.6.tgz":{"content_type":"application/octet-stream","revpos":40,"digest":"md5-0zKhp4jgk9avRZb12UaoDg==","length":7375,"stub":true},"utility-0.1.5.tgz":{"content_type":"application/octet-stream","revpos":38,"digest":"md5-uGvmW2lZnaAD/2Z/6KOsww==","length":7268,"stub":true},"utility-0.1.4.tgz":{"content_type":"application/octet-stream","revpos":36,"digest":"md5-uN2KnLJ3wDIPG6IvohPdAg==","length":6935,"stub":true},"utility-0.1.3.tgz":{"content_type":"application/octet-stream","revpos":34,"digest":"md5-DrCu2fZcgRHyIQtX91pdnQ==","length":6837,"stub":true},"utility-0.1.2.tgz":{"content_type":"application/octet-stream","revpos":32,"digest":"md5-DTjGQA0pVx18M2YM9qDI+g==","length":6405,"stub":true},"utility-0.1.1.tgz":{"content_type":"application/octet-stream","revpos":30,"digest":"md5-BJxUD2NlyRmH9XBJLsNF9g==","length":6306,"stub":true},"utility-0.1.0.tgz":{"content_type":"application/octet-stream","revpos":28,"digest":"md5-F7BlsEGDAMnWPRsjNDZX7w==","length":6207,"stub":true},"utility-0.0.13.tgz":{"content_type":"application/octet-stream","revpos":26,"digest":"md5-uBeqtoJa394Z4Iov+auXlA==","length":6095,"stub":true},"utility-0.0.12.tgz":{"content_type":"application/octet-stream","revpos":24,"digest":"md5-iuzu6wNoQnihEHLRrP20qQ==","length":6230,"stub":true},"utility-0.0.11.tgz":{"content_type":"application/octet-stream","revpos":22,"digest":"md5-bFdeXYsw88li52pefENCDw==","length":5871,"stub":true},"utility-0.0.10.tgz":{"content_type":"application/octet-stream","revpos":20,"digest":"md5-wMbTrEtGEPpn6jt/j30MeQ==","length":5813,"stub":true},"utility-0.0.9.tgz":{"content_type":"application/octet-stream","revpos":18,"digest":"md5-lC2SXYrxVY1AXYxmZEqqRw==","length":5380,"stub":true},"utility-0.0.8.tgz":{"content_type":"application/octet-stream","revpos":16,"digest":"md5-aEW6KYtjpW6OVlNRudUYKg==","length":5067,"stub":true},"utility-0.0.7.tgz":{"content_type":"application/octet-stream","revpos":14,"digest":"md5-Bmxt49GxXv5d4bWc34xGhQ==","length":4865,"stub":true},"utility-0.0.6.tgz":{"content_type":"application/octet-stream","revpos":12,"digest":"md5-p5D5Ys9L/oxwK4dHn7/OSw==","length":4842,"stub":true},"utility-0.0.5.tgz":{"content_type":"application/octet-stream","revpos":10,"digest":"md5-q6awJsgYERB66G+5l/bnKA==","length":4678,"stub":true},"utility-0.0.4.tgz":{"content_type":"application/octet-stream","revpos":8,"digest":"md5-YffzOqs/NLDYlw/ywk3mYg==","length":3484,"stub":true},"utility-0.0.3.tgz":{"content_type":"application/octet-stream","revpos":7,"digest":"md5-CXiC5mQWbk6b2V9fXcqOGA==","length":3031,"stub":true},"utility-0.0.2.tgz":{"content_type":"application/octet-stream","revpos":5,"digest":"md5-GU/i+K73gUSVUNFzwf4C5A==","length":2573,"stub":true},"utility-0.0.1.tgz":{"content_type":"application/octet-stream","revpos":3,"digest":"md5-6Q2gEca+BA3aCwbcLujRqg==","length":2022,"stub":true}}}
\ No newline at end of file