19 lines
520 B
TypeScript
19 lines
520 B
TypeScript
// #docregion
|
|
import {Pipe, PipeTransform} from 'angular2/core';
|
|
/*
|
|
* Raise the value exponentially
|
|
* Takes an exponent argument that defaults to 1.
|
|
* Usage:
|
|
* value | exponentialStrength:exponent
|
|
* Example:
|
|
* {{ 2 | exponentialStrength:10}}
|
|
* formats to: 1024
|
|
*/
|
|
@Pipe({name: 'exponentialStrength'})
|
|
export class ExponentialStrengthPipe implements PipeTransform {
|
|
transform(value:number, [exponent]) : number {
|
|
var exp = parseFloat(exponent);
|
|
return Math.pow(value, isNaN(exp) ? 1 : exp);
|
|
}
|
|
}
|