Skip to content

Commit

Permalink
2 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
sdgluck committed Feb 3, 2017
1 parent 35dcdd2 commit e640520
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

<p align="center">
<a href="http://badge.fury.io/js/tiny-tim"><img alt="npm version" src="https://badge.fury.io/js/tiny-tim.svg" /></a>
<a href="http://standardjs.com/"><img src="https://img.shields.io/badge/code%20style-standard-brightgreen.svg" /></a>
</p>

<hr/>

Comes in at `167 bytes` minified. Zero dependencies.
Comes in at `165 bytes` minified. Zero dependencies.

Tiny Tim is compiled using [`babili`](https://github.com/babel/babili) for ES6+ and CommonJS environments.

Expand Down
2 changes: 1 addition & 1 deletion lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"name": "tiny-tim",
"version": "0.0.2",
"version": "0.0.3",
"description": "Meet Tim, a small, simple timer",
"main": "lib/index.js",
"esnext:main": "src/index.js",
"scripts": {
"build": "rimraf lib && babili src -d lib",
"lint": "snazzy",
"test": "npm run build && node test.js",
"prepublishOnly": "npm run lint && npm run build"
"prepublishOnly": "npm run build"
},
"author": "Sam Gluck <[email protected]>",
"license": "MIT",
Expand All @@ -29,11 +28,5 @@
"snazzy": "^6.0.0",
"standard": "^7.1.1",
"tape": "^4.6.3"
},
"standard": {
"parser": "babel-eslint",
"ignore": [
"/lib"
]
}
}
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module.exports = (unit = 's', suffix) => {
var divs = { ms: 1, s: 1e3, m: 6e4, h: 36e5 }
var div = divs[unit] || divs.ms
var append = suffix && div ? unit : 0
var start = Date.now()
var start = +new Date

return () => {
var time = (Date.now() - start) / div
var time = (+new Date - start) / div
return (suffix !== 'ms' ? +time.toFixed(2) : time) + append
}
}
4 changes: 3 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ test('counts ok', (t) => {
const end = start + (1000 * 60 * 60)
const expected = end - start

Date.now = () => end
Date = function () {
this.valueOf = () => end
}

t.equals(ms() >= expected, true)
t.equals(s() >= expected / 1000, true)
Expand Down

0 comments on commit e640520

Please sign in to comment.