diff --git a/ms/ms-tests.ts b/ms/ms-tests.ts new file mode 100644 index 0000000000..75312e9277 --- /dev/null +++ b/ms/ms-tests.ts @@ -0,0 +1,14 @@ +/// + +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" \ No newline at end of file diff --git a/ms/ms.d.ts b/ms/ms.d.ts new file mode 100644 index 0000000000..5a7c67add2 --- /dev/null +++ b/ms/ms.d.ts @@ -0,0 +1,30 @@ +// Type definitions for ms v0.7.1 +// Project: https://github.com/guille/ms.js +// Definitions by: Zhiyuan Wang +// 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; +} \ No newline at end of file