diff --git a/oblo-util/oblo-util-tests.ts b/oblo-util/oblo-util-tests.ts new file mode 100644 index 000000000..401611ce7 --- /dev/null +++ b/oblo-util/oblo-util-tests.ts @@ -0,0 +1,29 @@ +/// + +util.debug = false; + +util.log('Log message'); + +util.error('Error message'); + +util.clip(0, 100, -15); + +util.square(3); + +util.replicate(10, 'x'); + +util.pad(' ', 10, 'short'); + +util.padZero(4, 247); + +util.addslashes('\\"\''); + +util.showJSON({name: 'Clyde', color: 'orange'}, ' ', 7); + +util.showTime(new Date()); + +util.showDate(new Date()); + +util.readDate('15-10-2004'); + +util.setAttr($('#someElement'), 'attrName', false); diff --git a/oblo-util/oblo-util.d.ts b/oblo-util/oblo-util.d.ts new file mode 100644 index 000000000..431cf36b3 --- /dev/null +++ b/oblo-util/oblo-util.d.ts @@ -0,0 +1,31 @@ +// Type definitions for oblo-util v0.6.4 +// Project: https://github.com/Oblosys/oblo-util +// Definitions by: Martijn Schrage +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +interface ObloUtilStatic { + debug : boolean; + + log(...args: any[]) : void; + error(...args: any[]) : void; + clip(min : number, max : number, x : number) : number; + square(x : number) : number; + replicate(n : number, x : X) : X[]; + pad(c : string, l : number, str : any) : string; + padZero(l : number, n : number) : string; + addslashes(str : string) : string; + showJSON(json : any, indentStr? : string, maxDepth? : number) : string; + showTime(date : Date) : string; + showDate(date : Date) : string; + readDate(dateStr : string) : Date; + setAttr($elt : JQuery, attrName : string, isSet : boolean) : void; +} + +declare var util: ObloUtilStatic; + +declare module "oblo-util" { + export = util; +}