Alex Eagle 93055f78ea chore(lint): require semicolons
Relying on ASI (automatic semicolon insertion)
is allowed in TypeScript because JavaScript allows
it. However, when we run clang-format it doesn’t
understand that these statements are terminated
with a newline and changes the indentation, in bad
cases even breaking the code.

Fixes #817
2015-07-15 12:57:32 -07:00

34 lines
768 B
TypeScript

import {isBlank, isPresent, Json, CONST} from 'angular2/src/facade/lang';
import {Pipe, BasePipe, PipeFactory} from './pipe';
import {ChangeDetectorRef} from '../change_detector_ref';
/**
* Implements json transforms to any object.
*
* # Example
*
* In this example we transform the user object to json.
*
* ```
* @Component({
* selector: "user-cmp"
* })
* @View({
* template: "User: {{ user | json }}"
* })
* class Username {
* user:Object
* constructor() {
* this.user = { name: "PatrickJS" };
* }
* }
*
* ```
*/
@CONST()
export class JsonPipe extends BasePipe implements PipeFactory {
transform(value, args: List<any> = null): string { return Json.stringify(value); }
create(cdRef: ChangeDetectorRef): Pipe { return this; }
}