Merge pull request #5476 from Oblosys/master

Add typings & tests for oblo-util-0.6.4
This commit is contained in:
Masahiro Wakame
2015-08-22 00:45:52 +09:00
2 changed files with 60 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
/// <reference path="oblo-util.d.ts" />
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);
+31
View File
@@ -0,0 +1,31 @@
// Type definitions for oblo-util v0.6.4
// Project: https://github.com/Oblosys/oblo-util
// Definitions by: Martijn Schrage <https://github.com/Oblosys/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
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<X>(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;
}