Skip to content

Commit

Permalink
alias Phasor as a synonym to Complex
Browse files Browse the repository at this point in the history
  • Loading branch information
brunocodutra committed Feb 22, 2018
1 parent ab121e4 commit 117b863
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ export type Complex = {
readonly tan: number,
};

export type Phasor = Complex;

export const isComplex = (p: any): p is Complex => (
typeof p === 'object' &&
'mag' in p && typeof p.mag === 'number' &&
'tan' in p && typeof p.tan === 'number'
);

export const isPhasor = isComplex;

const complex = (mag: number, tan: number): Complex => ({
mag: isNaN(tan) ? NaN : mag,
tan: isNaN(mag) ? NaN : tan,
Expand Down

0 comments on commit 117b863

Please sign in to comment.