From 56300b34b42912ecb5b4e6664ecd853f75ef34c2 Mon Sep 17 00:00:00 2001 From: Laurens Rietveld Date: Fri, 1 Jul 2016 14:10:29 +0200 Subject: [PATCH] updated ts definition for v2.4.0 of 'bytes' package with missing options --- bytes/bytes-tests.ts | 6 ++++-- bytes/bytes.d.ts | 13 +++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bytes/bytes-tests.ts b/bytes/bytes-tests.ts index 4a981aee47..31f2f78b4e 100644 --- a/bytes/bytes-tests.ts +++ b/bytes/bytes-tests.ts @@ -8,9 +8,11 @@ console.log(bytes(104857, { thousandsSeparator: ' ' })); console.log(bytes.format(104857)); console.log(bytes.format(104857, { thousandsSeparator: ' ' })); - +console.log(bytes.format(104857, { decimalPlaces: 2 })); +console.log(bytes.format(104857, { fixedDecimals: true })); +console.log(bytes.format(104857, { unitSeparator: '-' })); console.log(bytes('1024kb')); console.log(bytes(1024)); console.log(bytes.parse('1024kb')); -console.log(bytes.parse(1024)); \ No newline at end of file +console.log(bytes.parse(1024)); diff --git a/bytes/bytes.d.ts b/bytes/bytes.d.ts index b99ebee7c6..bd3a2f93bd 100644 --- a/bytes/bytes.d.ts +++ b/bytes/bytes.d.ts @@ -1,10 +1,15 @@ -// Type definitions for bytes v2.1.0 +// Type definitions for bytes v2.4.0 // Project: https://github.com/visionmedia/bytes.js // Definitions by: Zhiyuan Wang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module 'bytes' { - + interface BytesOptions { + decimalPlaces?: number, + thousandsSeparator?: string, + unitSeparator?: string, + fixedDecimals?: boolean + } /** *Convert the given value in bytes into a string. * @@ -15,7 +20,7 @@ declare module 'bytes' { * * @returns {string} */ - function bytes(value: number, options?: { thousandsSeparator: string }): string; + function bytes(value: number, options?: BytesOptions): string; /** *Parse string to an integer in bytes. @@ -37,7 +42,7 @@ declare module 'bytes' { * @param {BytesFormatOptions} [options] */ - function format(value: number, options?: { thousandsSeparator: string }): string; + function format(value: number, options?: BytesOptions): string; /** * Just return the input number value.