1 line
127 KiB
JSON
1 line
127 KiB
JSON
{"_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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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/>\"& &'); // '<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}}} |