Add new ss-utils API's + fix existing type definition

This commit is contained in:
Demis Bellot
2016-02-13 14:32:52 -05:00
parent bcd5761826
commit 229cb92825
2 changed files with 12 additions and 5 deletions
+5 -2
View File
@@ -58,12 +58,15 @@ function test_ssutils_Static(){
dateFmt = $.ss.dfmt(new Date(2001,1,1));
dateFmt = $.ss.dfmthm(new Date(2001,1,1));
dateFmt = $.ss.tfmt12(new Date(2001,1,1));
var parts:string[] = $.ss.splitOnFirst("A,B,C");
parts = $.ss.splitOnLast("A,B,C");
var parts:string[] = $.ss.splitOnFirst("A;B;C",";");
parts = $.ss.splitOnLast("A;B;C", ";");
var selectedText = $.ss.getSelection();
var qs:{ [index: string]: string } = $.ss.queryString("http://google.com?a=b&c=d");
var relativePath = $.ss.createUrl("/path/to/{File}", {File:"file.js"});
var readableText = $.ss.humanize("TheVariableName");
$.ss.normalizeKey("aAa");
$.ss.normalize({"AA":1,"bB":2,"C":{"A":11,"B":22},"D":[1,2],"E":[{"A":111,"B":222}]});
$.ss.normalize({"AA":1,"bB":2,"C":{"A":11,"B":22},"D":[1,2],"E":[{"A":111,"B":222}]}, true);
$.ss.parseResponseStatus('{"message":"test"}');
$.ss.postJSON("/path/to/url", {json:"data"}, function(r:any) {});
+7 -3
View File
@@ -17,12 +17,16 @@ declare namespace ssutils {
dfmt: (d: Date) => string;
dfmthm: (d: Date) => string;
tfmt12: (d: Date) => string;
splitOnFirst: (s: string) => string[];
splitOnLast: (s: string) => string[];
splitOnFirst: (s: string, delimiter:string) => string[];
splitOnLast: (s: string, delimiter: string) => string[];
getSelection: () => string;
combinePaths: (...paths:string[]) => string;
queryString: (url: string) => { [index: string]: string };
createUrl: (route: string, args?: any) => string;
createPath: (route: string, args: any) => string;
createUrl: (route: string, args: any) => string;
humanize: (s: string) => string;
normalizeKey: (key: string) => string;
normalize: (dto: any, deep?:boolean) => any;
parseResponseStatus: (json: string, defaultMsg?: string) => any;
postJSON: (url: string, data: Object | String, success?: Function, error?: Function) => any;