Skip to content

Latest commit

 

History

History
133 lines (132 loc) · 2.61 KB

README.md

File metadata and controls

133 lines (132 loc) · 2.61 KB

Tool.js

It can make your JavaScript tidy, and easy.
Creation concept: Less is more.
You can write very little, but implement many functions.
These were all developed by me alone, and it's not easy. Please give my repository a star. (Orz)

Slogan

Simple, Quick, Useful!

Usage

Prepare

var t = t(); //get the real "t"

Math

t.math.sum

Used for data summation:

t.math.sum([1,2,3]); // 6

t.math.mean

Used for averaging data:

t.math.mean([1,2,3]); // 2

t.math.variance

Used to calculate data variance:

t.math.variance([1,2,3]); //1

t.math.root

Used for opening root number any times:

t.math.root(2,2); //1.4142135623730951

Sort

t.sort.asc

Used for ascending sort:

t.sort.asc([68,64,6,0,34,6,35,613,2,5,59,60,4,65,53,1,5,29]); 
//[0,1,2,4,5,5,6,6,29,34,35,53,59,60,64,65,68,613]

t.sort.desc

Used for descending sort:

t.sort.desc([68,64,6,0,34,6,35,613,2,5,59,60,4,65,53,1,5,29])
//[613,68,65,64,60,59,53,35,34,29,6,6,5,5,4,2,1,0]

Is

t.is.num

t.is.num(1); //true
t.is.num("a"); //false

t.is.str

t.is.str(""); //true
t.is.str(0); //false

t.is.obj

t.is.obj({}); //true
t.is.obj(t); //true
t.is.obj(null); //true
t.is.obj([]); //true
t.is.obj(""); //false

t.is.arr

t.is.arr([]); //true
t.is.arr({}); //false

t.is.bool

t.is.bool(true); //true
t.is.bool(t.is.bool(false)) //true
t.is.bool(!0); //true
t.is.bool(1); //false

t.is.NaN

t.is.NaN("1"); //true
t.is.NaN(1); //false

t.is.undef

t.is.undef(undefined); //true
t.is.undef(t); //false

t.is.finite

t.is.finite(1.5); //true
t.is.finite(Infinity); //false

Types

t.types.toString

t.types.toSteing(1); //"1"

t.types.toArray

t.types.toArray(1); //[1]

t.types.toNumber

t.types.toNumber("1"); //1

t.types.toObject

t.types.toObject([1]); //{1}

t.types.toBoolean

t.types.toBoolean(1); //true
t.types.toBoolean(0); //false

Rand

t.rand.num

t.rand.num(1,100); //49
t.rand.num(1,1000000); //163784

t.rand.char

t.rand.char(); //"e"
t.rand.char(); //"%"
t.rand.char(); //"Q"
t.rand.char(); //"l"
t.rand.char(); //"#"

To be continued.

Star History

Star History Chart