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

Paste-bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.