All files / complex-js/functions abs.ts

100% Statements 5/5
100% Branches 3/3
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 131x     1x   1x 4x       4x    
import absImpl from '../internal/absImpl';
import { IComplex, IComplexConstructor } from '../internal/complex';
import mask from '../internal/mask';
import getAbs from '../methods/getAbs';
 
export default function abs<T extends IComplex>(Complex: IComplexConstructor<T>, z: IComplex | number, i = 0): T {
  const zAbs = typeof z === 'number'
    ? absImpl(z, i)
    : getAbs(z);
 
  return new Complex(zAbs, 0, zAbs, 0, mask.HAS_ALL);
}