Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: node-modules/humanize-ms
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: be36edb7d79c6fb4e16bafc9ee3d5e4ee83607c6
Choose a base ref
...
head repository: node-modules/humanize-ms
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e8bc10a223adeffe114966abc69b75e1f999ab65
Choose a head ref
  • 3 commits
  • 9 files changed
  • 2 contributors

Commits on Apr 5, 2015

  1. deps: upgrade ms to 0.7.0

    fengmk2 committed Apr 5, 2015
    Copy the full SHA
    4cf945f View commit details

Commits on Apr 6, 2015

  1. add benchmark

    fengmk2 committed Apr 6, 2015
    Copy the full SHA
    e584c58 View commit details

Commits on Apr 4, 2016

  1. Release 1.1.0

    不四 committed Apr 4, 2016
    Copy the full SHA
    e8bc10a View commit details
Showing with 79 additions and 16 deletions.
  1. +0 −5 .npmignore
  2. +2 −0 .travis.yml
  3. +6 −1 History.md
  4. +2 −2 Makefile
  5. +1 −1 README.md
  6. +1 −1 index.js
  7. +9 −6 package.json
  8. +56 −0 test/benchmark/ms.js
  9. +2 −0 test/index.test.js
5 changes: 0 additions & 5 deletions .npmignore

This file was deleted.

2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -2,5 +2,7 @@ language: node_js
node_js:
- "0.10"
- "0.11"
- "0.12"
- "iojs-1"
script: "make test-travis"
after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls"
7 changes: 6 additions & 1 deletion History.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

1.0.1 / 2014-12-31
1.1.0 / 2016-04-04
==================

* deps: upgrade ms to 0.7.0

1.0.1 / 2014-12-31
==================

* feat(index.js): warn when result is undefined
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
TESTS = test/*.test.js
REPORTER = tap
REPORTER = spec
TIMEOUT = 3000
MOCHA_OPTS =

install:
@npm install --registry=http://registry.npm.taobao.org
@npm install

test:
@NODE_ENV=test ./node_modules/mocha/bin/mocha \
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ $ npm install humanize-ms

## Examples

```
```js
var ms = require('humanize-ms');

ms('1s') // 1000
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -15,6 +15,6 @@ var ms = require('ms');
module.exports = function (t) {
if (typeof t === 'number') return t;
var r = ms(t);
if (r === undefined) console.warn('ms(%s) got undefined in %s', t, __filename);
if (r === undefined) console.warn('ms(%j) got undefined in %s', t, __filename);
return r;
};
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "humanize-ms",
"version": "1.0.1",
"version": "1.0.2",
"description": "transform humanize time to ms",
"main": "index.js",
"files": ["index.js"],
"scripts": {
"test": "make test"
},
@@ -21,12 +22,14 @@
},
"license": "MIT",
"dependencies": {
"ms": "~0.6.2"
"ms": "~0.7.0"
},
"devDependencies": {
"autod": "~0.3.2",
"istanbul": "~0.3.0",
"mocha": "~1.21.4",
"should": "~4.0.4"
"autod": "*",
"beautify-benchmark": "~0.2.4",
"benchmark": "~1.0.0",
"istanbul": "*",
"mocha": "*",
"should": "*"
}
}
56 changes: 56 additions & 0 deletions test/benchmark/ms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**!
* humanize-ms - test/benchmark/ms.js
*
* Copyright(c) node-modules and other contributors.
* MIT Licensed
*
* Authors:
* fengmk2 <m@fengmk2.com> (http://fengmk2.com)
*/

'use strict';

/**
* Module dependencies.
*/

var Benchmark = require('benchmark');
var benchmarks = require('beautify-benchmark');
var originMS = require('ms');
var ms = require('../..');

var suite = new Benchmark.Suite();

// add tests
suite

.add('origin ms()', function() {
originMS('10s');
})
.add('ms()', function() {
ms('10s');
})
.add('ms(1000)', function() {
ms(1000);
})

// add listeners
.on('cycle', function (event) {
benchmarks.add(event.target);
})
.on('start', function () {
console.log('\n node version: %s, date: %s\n Starting...', process.version, Date());
})
.on('complete', function() {
benchmarks.log();
})
// run async
.run({ 'async': false });

// node version: v1.6.3, date: Mon Apr 06 2015 11:59:04 GMT+0800 (CST)
// Starting...
// 3 tests completed.
//
// origin ms() x 3,393,695 ops/sec ±1.30% (92 runs sampled)
// ms() x 3,430,360 ops/sec ±1.05% (90 runs sampled)
// ms(1000) x 94,272,966 ops/sec ±1.11% (93 runs sampled)
2 changes: 2 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@ describe('humanize-ms', function () {
describe('when string', function () {
it('should transform to number', function () {
ms('1s').should.equal(1000);
ms('1m').should.equal(60000);
ms('1').should.equal(1);
});
});