http jsonp support added

This commit is contained in:
Vladimir Enchev
2015-09-07 10:52:49 +03:00
parent ddd65832c0
commit 4cf6b66939
5 changed files with 55 additions and 2 deletions

View File

@@ -20,6 +20,15 @@ export function copyFrom(source: any, target: any) {
}
}
export function parseJSON(source: string): any {
var src = source.trim();
if (src.lastIndexOf(")") === src.length - 1) {
return JSON.parse(src.substring(src.indexOf("(") + 1, src.lastIndexOf(")")));
}
return JSON.parse(src);
}
export module layout {
var MODE_SHIFT = 30;
@@ -39,6 +48,7 @@ export module layout {
return "Exact";
case layout.AT_MOST:
return "AtMost";
default:

6
utils/utils.d.ts vendored
View File

@@ -167,4 +167,10 @@
* @param uri The URI.
*/
export function isDataURI(uri: string): boolean
/**
* Returns object from JSON or JSONP string.
* @param source The JSON or JSONP string.
*/
export function parseJSON(source: string): any
}