You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

filesize.d.ts 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Type definitions for filesize 6.0.1
  2. // Project: https://github.com/avoidwork/filesize.js, https://filesizejs.com
  3. // Definitions by: Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>
  4. // Renaud Chaput <https://github.com/renchap>
  5. // Roman Nuritdinov <https://github.com/Ky6uk>
  6. // Sam Hulick <https://github.com/ffxsam>
  7. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  8. declare var fileSize: Filesize.Filesize;
  9. export = fileSize;
  10. export as namespace filesize;
  11. declare namespace Filesize {
  12. interface SiJedecBits {
  13. b?: string;
  14. Kb?: string;
  15. Mb?: string;
  16. Gb?: string;
  17. Tb?: string;
  18. Pb?: string;
  19. Eb?: string;
  20. Zb?: string;
  21. Yb?: string;
  22. }
  23. interface SiJedecBytes {
  24. B?: string;
  25. KB?: string;
  26. MB?: string;
  27. GB?: string;
  28. TB?: string;
  29. PB?: string;
  30. EB?: string;
  31. ZB?: string;
  32. YB?: string;
  33. }
  34. type SiJedec = SiJedecBits & SiJedecBytes & { [name: string]: string };
  35. interface Options {
  36. /**
  37. * Number base, default is 2
  38. */
  39. base?: number;
  40. /**
  41. * Enables bit sizes, default is false
  42. */
  43. bits?: boolean;
  44. /**
  45. * Specifies the SI suffix via exponent, e.g. 2 is MB for bytes, default is -1
  46. */
  47. exponent?: number;
  48. /**
  49. * Enables full form of unit of measure, default is false
  50. */
  51. fullform?: boolean;
  52. /**
  53. * Array of full form overrides, default is []
  54. */
  55. fullforms?: string[];
  56. /**
  57. * BCP 47 language tag to specify a locale, or true to use default locale, default is ""
  58. */
  59. locale?: string | boolean;
  60. /**
  61. * ECMA-402 number format option overrides, default is "{}"
  62. */
  63. localeOptions?: Intl.NumberFormatOptions;
  64. /**
  65. * Output of function (array, exponent, object, or string), default is string
  66. */
  67. output?: "array" | "exponent" | "object" | "string";
  68. /**
  69. * Decimal place, default is 2
  70. */
  71. round?: number;
  72. /**
  73. * Decimal separator character, default is `.`
  74. */
  75. separator?: string;
  76. /**
  77. * Character between the result and suffix, default is ` `
  78. */
  79. spacer?: string;
  80. /**
  81. * Standard unit of measure, can be iec or jedec, default is jedec; can be overruled by base
  82. */
  83. standard?: "iec" | "jedec";
  84. /**
  85. * Dictionary of SI/JEDEC symbols to replace for localization, defaults to english if no match is found
  86. */
  87. symbols?: SiJedec;
  88. /**
  89. * Enables unix style human readable output, e.g ls -lh, default is false
  90. */
  91. unix?: boolean;
  92. }
  93. interface Filesize {
  94. (bytes: number, options?: Options): string;
  95. partial: (options: Options) => ((bytes: number) => string);
  96. }
  97. }