JSPM

  • Created
  • Published
  • Downloads 459292
  • Score
    100M100P100Q172040F
  • License MIT

TypeScript definitions for bytes

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@types/bytes) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Installation

    npm install --save @types/bytes

    Summary

    This package contains type definitions for bytes (https://github.com/visionmedia/bytes.js).

    Details

    Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/bytes.

    index.d.ts

    /**
     * Convert the given value in bytes into a string.
     */
    declare function bytes(value: number, options?: bytes.BytesOptions): string | null;
    
    /**
     * Parse string to an integer in bytes.
     */
    declare function bytes(value: string): number | null;
    
    declare namespace bytes {
        type Unit = "b" | "gb" | "kb" | "mb" | "pb" | "tb" | "B" | "GB" | "KB" | "MB" | "PB" | "TB";
    
        interface BytesOptions {
            decimalPlaces?: number | undefined;
            fixedDecimals?: boolean | undefined;
            thousandsSeparator?: string | undefined;
            unit?: Unit | undefined;
            unitSeparator?: string | undefined;
        }
    
        /**
         * Format the given value in bytes into a string.
         *
         * If the value is negative, it is kept as such.
         * If it is a float, it is rounded.
         */
        function format(value: number, options?: BytesOptions): string | null;
    
        /**
         * Parse the string value into an integer in bytes.
         *
         * If no unit is given, it is assumed the value is in bytes.
         */
        function parse(value: string | number): number | null;
    }
    
    export = bytes;
    

    Additional Details

    • Last updated: Tue, 03 Dec 2024 08:37:26 GMT
    • Dependencies: none

    Credits

    These definitions were written by Zhiyuan Wang, Rickard Laurin, and Florian Keller.