refactor: remove some facades (#12335)

This commit is contained in:
Victor Berchet
2016-10-19 13:42:39 -07:00
committed by Alex Rickabaugh
parent 0ecd9b2df0
commit 76dd026447
58 changed files with 281 additions and 429 deletions

View File

@ -6,8 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Json, isString} from '../src/facade/lang';
import {isJsObject, stringToArrayBuffer} from './http_utils';
import {URLSearchParams} from './url_search_params';
@ -26,12 +24,12 @@ export abstract class Body {
* Attempts to return body as parsed `JSON` object, or raises an exception.
*/
json(): any {
if (isString(this._body)) {
return Json.parse(<string>this._body);
if (typeof this._body === 'string') {
return JSON.parse(<string>this._body);
}
if (this._body instanceof ArrayBuffer) {
return Json.parse(this.text());
return JSON.parse(this.text());
}
return this._body;
@ -54,7 +52,7 @@ export abstract class Body {
}
if (isJsObject(this._body)) {
return Json.stringify(this._body);
return JSON.stringify(this._body, null, 2);
}
return this._body.toString();