{"_id":"time-diff","_rev":"221086","name":"time-diff","description":"Returns the formatted, high-resolution time difference between `start` and `end` times.","dist-tags":{"latest":"0.3.1"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"time":{"modified":"2021-06-03T15:40:00.000Z","created":"2015-12-20T14:11:32.993Z","0.3.1":"2016-05-01T01:13:11.222Z","0.3.0":"2016-04-27T07:08:02.818Z","0.2.1":"2016-04-13T23:46:40.624Z","0.2.0":"2016-04-13T23:11:24.584Z","0.1.0":"2015-12-20T14:11:32.993Z"},"users":{},"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/time-diff.git"},"versions":{"0.3.1":{"name":"time-diff","description":"Returns the formatted, high-resolution time difference between `start` and `end` times.","version":"0.3.1","homepage":"https://github.com/jonschlinkert/time-diff","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/time-diff.git"},"bugs":{"url":"https://github.com/jonschlinkert/time-diff/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1","is-number":"^2.1.0","log-utils":"^0.1.0","pretty-time":"^0.2.0"},"devDependencies":{"gulp-format-md":"^0.1.7","minimist":"^1.2.0","mocha":"^2.4.5","strip-color":"^0.1.0"},"keywords":["console","diff","difference","elapse","elapsed","log","pretty","terminal","time","time-diff","timer"],"verb":{"plugins":["gulp-format-md"],"reflinks":["pretty-time","verb","minimist"],"related":{"list":["ansi-colors","log-utils","pretty-time","time-diff"]},"layout":"default","toc":{"render":false},"run":true,"lint":{"reflinks":true},"tasks":["readme"]},"gitHead":"8aec8b9a6f15f3bf371e972e70d5a7b3debe826e","_id":"time-diff@0.3.1","_shasum":"25e8fb734eea9e6cb5e4b0394f05810b9c87c2d8","_from":".","_npmVersion":"3.6.0","_nodeVersion":"5.5.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"25e8fb734eea9e6cb5e4b0394f05810b9c87c2d8","size":4895,"noattachment":false,"key":"/time-diff/-/time-diff-0.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/time-diff/download/time-diff-0.3.1.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/time-diff-0.3.1.tgz_1462065188943_0.5811526137404144"},"directories":{},"publish_time":1462065191222,"_cnpm_publish_time":1462065191222,"_hasShrinkwrap":false},"0.3.0":{"name":"time-diff","description":"Returns the formatted, high-resolution time difference between `start` and `end` times.","version":"0.3.0","homepage":"https://github.com/jonschlinkert/time-diff","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/time-diff.git"},"bugs":{"url":"https://github.com/jonschlinkert/time-diff/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1","is-number":"^2.1.0","log-utils":"^0.1.0","pretty-time":"^0.2.0"},"devDependencies":{"gulp-format-md":"^0.1.7","minimist":"^1.2.0","mocha":"^2.4.5","strip-color":"^0.1.0"},"keywords":["console","diff","difference","elapse","elapsed","log","pretty","terminal","time","time-diff","timer"],"verb":{"plugins":["gulp-format-md"],"reflinks":["pretty-time","verb","minimist"],"related":{"list":["ansi-colors","log-utils","pretty-time","time-diff"]},"layout":"default","toc":{"render":false},"run":true,"lint":{"reflinks":true},"tasks":["readme"]},"gitHead":"421eeebe70057c53ae0c3a4e7e4436a536be06de","_id":"time-diff@0.3.0","_shasum":"0b4d53c563e40e5263e09252611445f46fa407ba","_from":".","_npmVersion":"3.6.0","_nodeVersion":"5.5.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"0b4d53c563e40e5263e09252611445f46fa407ba","size":4867,"noattachment":false,"key":"/time-diff/-/time-diff-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/time-diff/download/time-diff-0.3.0.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/time-diff-0.3.0.tgz_1461740881907_0.12482427293434739"},"directories":{},"publish_time":1461740882818,"_cnpm_publish_time":1461740882818,"_hasShrinkwrap":false},"0.2.1":{"name":"time-diff","description":"Returns the formatted, high-resolution time difference between `start` and `end` times.","version":"0.2.1","homepage":"https://github.com/jonschlinkert/time-diff","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/time-diff.git"},"bugs":{"url":"https://github.com/jonschlinkert/time-diff/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1","is-number":"^2.1.0","log-utils":"^0.1.0","pretty-time":"^0.2.0"},"devDependencies":{"gulp-format-md":"^0.1.7","minimist":"^1.2.0","mocha":"^2.4.5","strip-color":"^0.1.0"},"keywords":["console","diff","difference","elapse","elapsed","log","pretty","terminal","time","time-diff","timer"],"verb":{"plugins":["gulp-format-md"],"reflinks":["pretty-time","verb"],"related":{"list":["log-utils","time-diff","pretty-time","ansi-colors"]},"layout":"default","toc":{"render":false},"run":true,"lint":{"reflinks":true},"tasks":["readme"]},"gitHead":"421eeebe70057c53ae0c3a4e7e4436a536be06de","_id":"time-diff@0.2.1","_shasum":"b749e43d5cb47b91d29d496fae3deef035ddc534","_from":".","_npmVersion":"3.6.0","_nodeVersion":"5.5.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"b749e43d5cb47b91d29d496fae3deef035ddc534","size":4321,"noattachment":false,"key":"/time-diff/-/time-diff-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/time-diff/download/time-diff-0.2.1.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/time-diff-0.2.1.tgz_1460591198229_0.45759615139104426"},"directories":{},"publish_time":1460591200624,"_cnpm_publish_time":1460591200624,"_hasShrinkwrap":false},"0.2.0":{"name":"time-diff","description":"Returns the formatted, high-resolution time difference between `start` and `end` times.","version":"0.2.0","homepage":"https://github.com/jonschlinkert/time-diff","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/time-diff.git"},"bugs":{"url":"https://github.com/jonschlinkert/time-diff/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1","is-number":"^2.1.0","log-utils":"^0.1.0","pretty-time":"^0.2.0"},"devDependencies":{"gulp-format-md":"^0.1.7","minimist":"^1.2.0","mocha":"^2.4.5","strip-color":"^0.1.0"},"keywords":["console","diff","difference","elapse","elapsed","log","pretty","terminal","time","time-diff","timer"],"verb":{"plugins":["gulp-format-md"],"reflinks":["pretty-time","verb"],"related":{"list":["log-utils","time-diff","pretty-time","ansi-colors"]},"layout":"default","toc":{"render":false},"run":true,"lint":{"reflinks":true},"tasks":["readme"]},"gitHead":"d5c13a93828f4a5618133ef05e3248da5c480b8c","_id":"time-diff@0.2.0","_shasum":"8c3f9d462d7780c6b9a4a4152fa36c1cc3c2b23f","_from":".","_npmVersion":"3.6.0","_nodeVersion":"5.5.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"8c3f9d462d7780c6b9a4a4152fa36c1cc3c2b23f","size":4223,"noattachment":false,"key":"/time-diff/-/time-diff-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/time-diff/download/time-diff-0.2.0.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/time-diff-0.2.0.tgz_1460589082850_0.768518908880651"},"directories":{},"publish_time":1460589084584,"_cnpm_publish_time":1460589084584,"_hasShrinkwrap":false},"0.1.0":{"name":"time-diff","description":"Returns the formatted, high-resolution time difference between `start` and `end` times.","version":"0.1.0","homepage":"https://github.com/jonschlinkert/time-diff","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/time-diff.git"},"bugs":{"url":"https://github.com/jonschlinkert/time-diff/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"ansi-red":"^0.1.1","is-number":"^2.1.0","pretty-time":"^0.2.0"},"devDependencies":{"mocha":"*"},"keywords":["log","time"],"verb":{"related":{"list":["pretty-time"]},"plugins":["gulp-format-md"],"reflinks":["pretty-time"],"layout":"default"},"gitHead":"05bba76c39637c6a073a75f117c347bd12730e21","_id":"time-diff@0.1.0","_shasum":"17cf734f32ad6077a35dd3c79f42d5b31a8aebd6","_from":".","_npmVersion":"3.3.6","_nodeVersion":"5.0.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"17cf734f32ad6077a35dd3c79f42d5b31a8aebd6","size":2742,"noattachment":false,"key":"/time-diff/-/time-diff-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/time-diff/download/time-diff-0.1.0.tgz"},"directories":{},"publish_time":1450620692993,"_cnpm_publish_time":1450620692993,"_hasShrinkwrap":false}},"readme":"# time-diff [![NPM version](https://img.shields.io/npm/v/time-diff.svg?style=flat)](https://www.npmjs.com/package/time-diff) [![NPM downloads](https://img.shields.io/npm/dm/time-diff.svg?style=flat)](https://npmjs.org/package/time-diff) [![Build Status](https://img.shields.io/travis/jonschlinkert/time-diff.svg?style=flat)](https://travis-ci.org/jonschlinkert/time-diff)\n\nReturns the formatted, high-resolution time difference between `start` and `end` times.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install time-diff --save\n```\n\n## Usage\n\nUses [pretty-time][] to format time diffs.\n\n```js\nvar Time = require('time-diff');\nvar time = new Time();\n\n// create a start time for `foo`\ntime.start('foo');\n\n// call `end` wherever the `foo` process ends\nconsole.log(time.end('foo'));\n//=> 12ms\n```\n\n## API\n\n### [.start](index.js#L57)\n\nStart a timer for the given `name`.\n\n**Params**\n\n* `name` **{String}**: Name to use for the starting time.\n* `returns` **{Array}**: Returns the array from `process.hrtime()`\n\n**Example**\n\n```js\nvar time = new Time();\ntime.start('foo');\n```\n\n### [.end](index.js#L86)\n\nReturns the cumulative elapsed time since the **first time** `time.start(name)` was called.\n\n**Params**\n\n* `name` **{String}**: The name of the cached starting time to create the diff\n* `returns` **{Array}**: Returns the array from `process.hrtime()`\n\n**Example**\n\n```js\nvar time = new Time();\ntime.start('foo');\n\n// do stuff\ntime.end('foo');\n//=> 104μs\n\n// do more stuff\ntime.end('foo');\n//=> 1ms\n\n// do more stuff\ntime.end('foo');\n//=> 2ms\n```\n\n### [.diff](index.js#L134)\n\nReturns a function for logging out out both the cumulative elapsed time since the first time `.diff(name)` was called, as well as the incremental elapsed time since the last `.diff(name)` was called. Unlike `.end()`, this method logs to `stderr` instead of returning a string. We could probably change this to return an object, feedback welcome.\n\nResults in something like:\n<br>\n<img width=\"509\" alt=\"screen shot 2016-04-13 at 7 45 12 pm\" src=\"https://cloud.githubusercontent.com/assets/383994/14512800/478e1256-01b0-11e6-9e97-c6b625f097f7.png\">\n\n**Params**\n\n* `name` **{String}**: The name of the starting time to store.\n* `options` **{String}**\n\n**Example**\n\n```js\nvar time = new Time();\nvar diff = time.diff('my-app-name');\n\n// do stuff\ndiff('after init');\n//=> [19:44:05] my-app-name: after init 108μs\n\n// do more stuff\ndiff('before options');\n//=> [19:44:05] my-app-name: before options 2ms (+2ms)\n\n// do more stuff\ndiff('after options');\n//=> [19:44:05] my-app-name: after options 2ms (+152μs)\n```\n\n## Options\n\n### options.logDiff\n\nDisable time diffs, or filter time diffs to the specified name(s).\n\n**type**: `Boolean|String`\n\n**default**: `undefined`\n\n### options.nocolor\n\nSet to `true` to disable color in the output.\n\n**type**: `Boolean`\n\n**default**: `undefined`\n\n**Example**\n\n```js\nvar diff = time.diff('foo', {nocolor: true});\n```\n\n### options.formatArgs\n\nFormat arguments passed to `process.stderr`.\n\n**type**: `Function`\n\n**default**: `undefined`\n\n**Examples**\n\nShow `message` and `elapsed` time only:\n\n```js\nvar time = new Time();\nvar diff = time.diff('foo', {\n  formatArgs: function(timestamp, name, msg, elapsed) {\n    return [msg, elapsed];\n  }\n});\n\ndiff('first diff');\n//=> 'first diff 36μs'\ndiff('second diff');\n//=> 'second diff 71μs'\n```\n\nShow `name` and `elapsed` time only:\n\n```js\nvar diff = time.diff('foo', {\n  formatArgs: function(timestamp, name, msg, elapsed) {\n    return [name, elapsed];\n  }\n});\n\ndiff('first diff');\n//=> 'foo 36μs'\ndiff('second diff');\n//=> 'foo 71μs'\n```\n\n## Examples\n\nCreate an instance of `Time`, optionally specifying the time scale to use and the number of decimal places to display.\n\n**Options**\n\n* `options.smallest`: the smallest time scale to show\n* `options.digits`: the number of decimal places to display (`digits`)\n\n**Examples**\n\n_(See [pretty-time][] for all available formats)_\n\nGiven the following:\n\n```js\nvar time = new Time(options);\ntime.start('foo');\n```\n\nReturns milliseconds by default\n\n```js\nconsole.log(time.end('foo'));\n//=> 13ms\n```\n\nMilliseconds to 3 decimal places\n\n```js\nconsole.log(time.end('foo', 'ms', 3));\n// or\nconsole.log(time.end('foo', 3));\n//=> 12.743ms\n```\n\nSeconds to 3 decimal places\n\n```js\nconsole.log(time.end('foo', 's', 3));\n//=> 0.013s\n```\n\nSeconds\n\n```js\nconsole.log(time.end('foo', 's'));\n//=> 0s\n```\n\nMicroseconds\n\n```js\nconsole.log(time.end('foo', 'μs'));\n//=> 12ms 934μs\n```\n\nMicroseconds to 2 decimal places\n\n```js\nconsole.log(time.end('foo', 'μs', 2));\n//=> 14ms 435.78μs\n```\n\nnano-seconds\n\n```js\nconsole.log(time.end('foo', 'n', 3));\n//=> 13ms 796μs 677ns\n```\n\nnano-seconds to 3 decimal places\n\n```js\nconsole.log(time.end('foo', 'n', 3));\n//=> 13ms 427μs 633.000ns\n```\n\n## CLI usage\n\nIf you're using `time-diff` with a command line application, try using [minimist][] for setting options.\n\n```js\nvar opts = {alias: {nocolor: 'n', logTime: 't', logDiff: 'd'}};\nvar argv = require('minimist')(process.argv.slice(2), opts);\n\nvar Time = require('time-diff');\nvar time = new Time(argv);\n```\n\n## Related projects\n\nYou might also be interested in these projects:\n\n* [ansi-colors](https://www.npmjs.com/package/ansi-colors): Collection of ansi colors and styles. | [homepage](https://github.com/doowb/ansi-colors)\n* [log-utils](https://www.npmjs.com/package/log-utils): Basic logging utils: colors, symbols and timestamp. | [homepage](https://github.com/jonschlinkert/log-utils)\n* [pretty-time](https://www.npmjs.com/package/pretty-time): Easily format the time from node.js `process.hrtime`. Works with timescales ranging from weeks to nanoseconds. | [homepage](https://github.com/jonschlinkert/pretty-time)\n* [time-diff](https://www.npmjs.com/package/time-diff): Returns the formatted, high-resolution time difference between `start` and `end` times. | [homepage](https://github.com/jonschlinkert/time-diff)\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/time-diff/issues/new).\n\n## Building docs\n\nGenerate readme and API documentation with [verb][]:\n\n```sh\n$ npm install verb && npm run docs\n```\n\nOr, if [verb][] is installed globally:\n\n```sh\n$ verb\n```\n\n## Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm install -d && npm test\n```\n\n## Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n## License\n\nCopyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT license](https://github.com/jonschlinkert/time-diff/blob/master/LICENSE).\n\n***\n\n_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on April 30, 2016._\n\n[pretty-time](https://github.com/jonschlinkert/pretty-time)\n[minimist](https://github.com/substack/minimist)\n[verb](https://github.com/verbose/verb)","_attachments":{},"homepage":"https://github.com/jonschlinkert/time-diff","bugs":{"url":"https://github.com/jonschlinkert/time-diff/issues"},"license":"MIT"}