fraction.d.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. declare module 'Fraction';
  2. export interface NumeratorDenominator {
  3. n: number;
  4. d: number;
  5. }
  6. type FractionConstructor = {
  7. (fraction: Fraction): Fraction;
  8. (num: number | string): Fraction;
  9. (numerator: number, denominator: number): Fraction;
  10. (numbers: [number | string, number | string]): Fraction;
  11. (fraction: NumeratorDenominator): Fraction;
  12. (firstValue: Fraction | number | string | [number | string, number | string] | NumeratorDenominator, secondValue?: number): Fraction;
  13. };
  14. export default class Fraction {
  15. constructor (fraction: Fraction);
  16. constructor (num: number | string);
  17. constructor (numerator: number, denominator: number);
  18. constructor (numbers: [number | string, number | string]);
  19. constructor (fraction: NumeratorDenominator);
  20. constructor (firstValue: Fraction | number | string | [number | string, number | string] | NumeratorDenominator, secondValue?: number);
  21. s: number;
  22. n: number;
  23. d: number;
  24. abs(): Fraction;
  25. neg(): Fraction;
  26. add: FractionConstructor;
  27. sub: FractionConstructor;
  28. mul: FractionConstructor;
  29. div: FractionConstructor;
  30. pow: FractionConstructor;
  31. gcd: FractionConstructor;
  32. lcm: FractionConstructor;
  33. mod(n?: number | string | Fraction): Fraction;
  34. ceil(places?: number): Fraction;
  35. floor(places?: number): Fraction;
  36. round(places?: number): Fraction;
  37. inverse(): Fraction;
  38. simplify(eps?: number): Fraction;
  39. equals(n: number | string | Fraction): boolean;
  40. compare(n: number | string | Fraction): number;
  41. divisible(n: number | string | Fraction): boolean;
  42. valueOf(): number;
  43. toString(decimalPlaces?: number): string;
  44. toLatex(excludeWhole?: boolean): string;
  45. toFraction(excludeWhole?: boolean): string;
  46. toContinued(): number[];
  47. clone(): Fraction;
  48. }