add definitions and tests for NodeJs package ms v0.7.1

This commit is contained in:
Zhiyuan Wang 2015-10-31 20:04:55 +08:00
parent b1956785d6
commit 4331a333df
2 changed files with 44 additions and 0 deletions

14
ms/ms-tests.ts Normal file
View File

@ -0,0 +1,14 @@
/// <reference path="./ms.d.ts"/>
import ms = require('ms');
ms('2 days') // 172800000
ms('1d') // 86400000
ms(60000) // "1m"
ms(2 * 60000) // "2m"
ms(ms('10 hours')) // "10h"
ms(60000, { long: true }) // "1 minute"
ms(2 * 60000, { long: true }) // "2 minutes"
ms(ms('10 hours'), { long: true }) // "10 hours"

30
ms/ms.d.ts vendored Normal file
View File

@ -0,0 +1,30 @@
// Type definitions for ms v0.7.1
// Project: https://github.com/guille/ms.js
// Definitions by: Zhiyuan Wang <https://github.com/danny8002/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'ms' {
interface IMSOptions {
long: boolean
}
/**
* Short/Long format for `value`.
*
* @param {Number} value
* @param {{long: boolean}} options
* @return {String}
*/
function ms(value: number, options?: IMSOptions): string;
/**
* Parse the given `value` and return milliseconds.
*
* @param {String} value
* @return {Number}
*/
function ms(value: string): number;
export = ms;
}