WhatsIt
A small util class.
The plugin is only available for Node.JS currently.
Install package
npm install whatsit --save
TF stands for Team First
Include package
var W = ;
Functions available
type:
Also checks for email, url, phone number(uses libphonenumber library), NaN, Float, Int and Infinity types
Wtype"hello world"; //'String'Wtype123; //'Int'Wtype12323; //'Float'WtypeNaN; //'NaN'WtypeInfinity; //'Number'Wtype-Infinity; //'Number'Wtype{}; //'Object'Wtypeundefined; //'Undefined'Wtype; //'Array'Wtypetrue; //'Boolean'Wtype; //'Date'Wtypenull; //'Null'Wtype"test@test.com"; //'Email'Wtype"http://www.google.com/?q=testing"; //'Url'Wtype"+44 7700 900804"; //'Phone'
trueType:
Just check for type and returns true javascript type for an object 1
Wtype"hello world"; //'String'Wtype123; //'Number'Wtype12323; //'Number'WtypeNaN; //'Number'WtypeInfinity; //'Number'Wtype-Infinity; //'Number'Wtype{}; //'Object'Wtypeundefined; //'Undefined'Wtype; //'Array'Wtypetrue; //'Boolean'Wtype; //'Date'Wtypenull; //'Null'Wtype"test@test.com"; //'String'Wtype"http://www.google.com/?q=testing"; //'String'Wtype"+44 7700 900804"; //'String'
isNaN:
W; //trueW; //false
isFalsey:
Even checks for empty object and array.
W; //trueW; //trueW; //trueW; //trueW; //trueW; //trueW; //trueW; //trueW; //trueW; //true
isEmpty:
Same as isFalsey but it returns false for false and 0. This helps to check required fields
W; //falseW; //trueW; //falseW; //trueW; //trueW; //trueW; //trueW; //trueW; //trueW; //false
trim:
W; //""W; //"hello"W; //["hello"]
prefixInArray:
W; //["Hello", "Hola"]W; //["Hello", "Hola"]);W; //[]W; //["Hello", "Hola", "Welcome"]W; //nullW; //["Hello", "Hola", "Welcome"]W; //["Hello", "Hola"]
sufixInArray:
W; //["Hole", "Welcome"]W; //["Hole", "Welcome"]W; //[]W; //["Hello", "Hola", "Welcome"]W; //nullW; //["Hello", "Hola", "Welcome"]
findInArray:
W; //["Hello", "Welcome"]W; //["Hello", "Welcome"]);W; //[]W; //["Hello", "Hola", "Welcome"]W; //nullW; //["Hello", "Hola", "Welcome"]
for
does for in loop and checks for hasOwnProperty for both objects and arrays in one line.
W;W;W; //throws an error 'Unexpected type'W // returns undefined
LICENSE
The MIT License (MIT)