mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
add definitions and tests for NodeJs package ms v0.7.1
This commit is contained in:
parent
b1956785d6
commit
4331a333df
14
ms/ms-tests.ts
Normal file
14
ms/ms-tests.ts
Normal 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
30
ms/ms.d.ts
vendored
Normal 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;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user