mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[bytes] Update to v3.1.0 (#40285)
This commit is contained in:
parent
8c1bc9265b
commit
dbccba2911
@ -1,23 +1,21 @@
|
||||
import bytes = require('bytes');
|
||||
|
||||
// 1024*1024 = 1048576
|
||||
console.log(bytes(undefined));
|
||||
console.log(bytes(null));
|
||||
bytes(104857);
|
||||
bytes(104857, { thousandsSeparator: ' ' });
|
||||
bytes(104857, { decimalPlaces: 2 });
|
||||
bytes(104857, { fixedDecimals: true });
|
||||
bytes(104857, { unitSeparator: '-' });
|
||||
bytes(104857, { unit: 'GB' });
|
||||
bytes(104857, { unit: 'B' });
|
||||
|
||||
console.log(bytes(104857));
|
||||
console.log(bytes(104857, { thousandsSeparator: ' ' }));
|
||||
console.log(bytes(104857, { decimalPlaces: 2 }));
|
||||
console.log(bytes(104857, { fixedDecimals: true }));
|
||||
console.log(bytes(104857, { unitSeparator: '-' }));
|
||||
console.log(bytes(104857, { unit: 'GB' }));
|
||||
bytes.format(104857);
|
||||
bytes.format(104857, { thousandsSeparator: ' ' });
|
||||
bytes.format(104857, { decimalPlaces: 2 });
|
||||
bytes.format(104857, { fixedDecimals: true });
|
||||
bytes.format(104857, { unitSeparator: '-' });
|
||||
bytes.format(104857, { unit: 'GB' });
|
||||
bytes.format(104857, { unit: 'pb' });
|
||||
|
||||
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.format(104857, { unit: 'GB' }));
|
||||
|
||||
console.log(bytes('1024kb'));
|
||||
console.log(bytes.parse('1024kb'));
|
||||
console.log(bytes.parse(1024));
|
||||
bytes('1024kb');
|
||||
bytes.parse('1024kb');
|
||||
bytes.parse(1024);
|
||||
|
||||
23
types/bytes/index.d.ts
vendored
23
types/bytes/index.d.ts
vendored
@ -1,21 +1,14 @@
|
||||
// Type definitions for bytes 3.0
|
||||
// Type definitions for bytes 3.1
|
||||
// Project: https://github.com/visionmedia/bytes.js
|
||||
// Definitions by: Zhiyuan Wang <https://github.com/danny8002>
|
||||
// Rickard Laurin <https://github.com/believer>
|
||||
// Florian Keller <https://github.com/ffflorian>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface BytesOptions {
|
||||
decimalPlaces?: number;
|
||||
thousandsSeparator?: string;
|
||||
unitSeparator?: string;
|
||||
fixedDecimals?: boolean;
|
||||
unit?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given value in bytes into a string.
|
||||
*/
|
||||
declare function bytes(value: number, options?: BytesOptions): string;
|
||||
declare function bytes(value: number, options?: bytes.BytesOptions): string;
|
||||
|
||||
/**
|
||||
* Parse string to an integer in bytes.
|
||||
@ -23,6 +16,16 @@ declare function bytes(value: number, options?: BytesOptions): string;
|
||||
declare function bytes(value: string): number;
|
||||
|
||||
declare namespace bytes {
|
||||
type Unit = 'b' | 'gb' | 'kb' | 'mb' | 'pb' | 'tb' | 'B' | 'GB' | 'KB' | 'MB' | 'PB' | 'TB';
|
||||
|
||||
interface BytesOptions {
|
||||
decimalPlaces?: number;
|
||||
fixedDecimals?: boolean;
|
||||
thousandsSeparator?: string;
|
||||
unit?: Unit;
|
||||
unitSeparator?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the given value in bytes into a string.
|
||||
*
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@ -21,4 +21,4 @@
|
||||
"index.d.ts",
|
||||
"bytes-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user