Merge pull request #30300 from gricey432/master

is: Update environment functions
This commit is contained in:
Armando Aguirre 2018-11-07 15:22:53 -08:00 committed by GitHub
commit c66b68d99f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 76 additions and 13 deletions

46
types/is/index.d.ts vendored
View File

@ -1,8 +1,10 @@
// Type definitions for is.js
// Project: http://arasatasaygin.github.io/is.js/
// Definitions by: Rodrigo Cabral <https://github.com/cabralRodrigo>
// Definitions by: Rodrigo Cabral <https://github.com/cabralRodrigo>, Mitchell Grice <https://github.com/gricey432>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
type EnvironmentVersionRange = number | string;
interface IsStatic {
//#region Type checks
@ -367,29 +369,45 @@ interface IsStatic {
/**
* Checks if current browser is ie
* @parm value Optional version number of browser
* @parm value Optional version range of browser
*/
ie(value?: number): boolean;
ie(range?: EnvironmentVersionRange): boolean;
/**
* Checks if current browser is chrome.
* @parm value Optional version range of browser
*/
chrome(): boolean;
chrome(range?: EnvironmentVersionRange): boolean;
/**
* Checks if current browser is firefox.
* @parm value Optional version range of browser
*/
firefox(): boolean;
firefox(range?: EnvironmentVersionRange): boolean;
/**
* Checks if current browser is edge.
* @parm value Optional version range of browser
*/
edge(range?: EnvironmentVersionRange): boolean;
/**
* Checks if current browser is opera.
* @parm value Optional version range of browser
*/
opera(): boolean;
opera(range?: EnvironmentVersionRange): boolean;
/**
* Checks if current browser is safari.
* @parm value Optional version range of browser
*/
safari(): boolean;
safari(range?: EnvironmentVersionRange): boolean;
/**
* Checks if current browser is phantom.
* @parm value Optional version range of browser
*/
phantom(range?: EnvironmentVersionRange): boolean;
/**
* Checks if current device has ios.
@ -398,18 +416,21 @@ interface IsStatic {
/**
* Checks if current device is iPhone.
* @parm value Optional version range of device
*/
iphone(): boolean;
iphone(range?: EnvironmentVersionRange): boolean;
/**
* Checks if current device is iPad.
* @parm value Optional version range of device
*/
ipad(): boolean;
ipad(range?: EnvironmentVersionRange): boolean;
/**
* Checks if current device is iPod.
* @parm value Optional version range of device
*/
ipod(): boolean;
ipod(range?: EnvironmentVersionRange): boolean;
/**
* Checks if current device has Android.
@ -481,6 +502,11 @@ interface IsStatic {
*/
offline(): boolean;
/**
* Checks if current device supports touch.
*/
touchDevice(): boolean;
//#endregion
//#region Time checks

View File

@ -446,32 +446,67 @@ is.all.sorted([[1, 2], [5, 4]]);
//#region Environment checks
is.ie();
is.ie(6);
is.not.ie();
is.ie(10);
is.ie('>=10');
is.not.ie('<9');
is.chrome();
is.not.chrome();
is.chrome(50);
is.chrome('>=40');
is.not.chrome('<30');
is.firefox();
is.not.firefox();
is.firefox(41);
is.firefox('>=40');
is.not.firefox('<30');
is.edge();
is.not.edge();
is.edge(13);
is.edge('>=12');
is.not.edge('<13');
is.opera();
is.not.opera();
is.opera(36);
is.opera('>=35');
is.not.opera('<20');
is.safari();
is.not.safari();
is.safari(9);
is.safari('>=8');
is.not.safari('<7');
is.phantom();
is.not.phantom();
is.phantom(2);
is.phantom('>=1');
is.not.phantom('<2');
is.ios();
is.not.ios();
is.iphone();
is.not.iphone();
is.iphone(9);
is.iphone('>=7');
is.not.iphone('<8');
is.ipad();
is.not.ipad();
is.ipad(9);
is.ipad('>=7');
is.not.ipad('<8');
is.ipod();
is.not.ipod();
is.ipod(7);
is.ipod('>=5');
is.not.ipod('<5');
is.android();
is.not.android();
@ -483,7 +518,6 @@ is.androidTablet();
is.not.androidTablet();
is.blackberry();
is.not.blackberry();
is.windowsPhone();
@ -516,6 +550,9 @@ is.not.online();
is.offline();
is.not.offline();
is.touchDevice();
is.not.touchDevice();
//#endregion
//#region Time checks
@ -664,4 +701,4 @@ is.url('quack');
var customName = is.setNamespace();
customName.odd(3);
//#endregion
//#endregion