From 22404698d15ba1e2324e7fbc21f0d733456b515e Mon Sep 17 00:00:00 2001 From: Mitchell Grice Date: Tue, 6 Nov 2018 11:25:56 +1000 Subject: [PATCH 1/2] is: add edge --- types/is/index.d.ts | 5 +++++ types/is/is-tests.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/types/is/index.d.ts b/types/is/index.d.ts index 37b485e0a0..adb4f7d43a 100644 --- a/types/is/index.d.ts +++ b/types/is/index.d.ts @@ -371,6 +371,11 @@ interface IsStatic { */ ie(value?: number): boolean; + /** + * Checks if current browser is edge. + */ + edge(): boolean; + /** * Checks if current browser is chrome. */ diff --git a/types/is/is-tests.ts b/types/is/is-tests.ts index 77a88a81b3..b710bd0db0 100644 --- a/types/is/is-tests.ts +++ b/types/is/is-tests.ts @@ -449,6 +449,9 @@ is.ie(); is.ie(6); is.not.ie(); +is.edge(); +is.not.edge(); + is.chrome(); is.not.chrome(); @@ -664,4 +667,4 @@ is.url('quack'); var customName = is.setNamespace(); customName.odd(3); -//#endregion \ No newline at end of file +//#endregion From 9c1a9e6b462c7dfc530b40af430061b4989956ef Mon Sep 17 00:00:00 2001 From: Mitchell Grice Date: Wed, 7 Nov 2018 09:10:03 +1000 Subject: [PATCH 2/2] is: update all environment functions --- types/is/index.d.ts | 51 +++++++++++++++++++++++++++++++------------- types/is/is-tests.ts | 44 +++++++++++++++++++++++++++++++++----- 2 files changed, 75 insertions(+), 20 deletions(-) diff --git a/types/is/index.d.ts b/types/is/index.d.ts index adb4f7d43a..9129f7d664 100644 --- a/types/is/index.d.ts +++ b/types/is/index.d.ts @@ -1,8 +1,10 @@ // Type definitions for is.js // Project: http://arasatasaygin.github.io/is.js/ -// Definitions by: Rodrigo Cabral +// Definitions by: Rodrigo Cabral , Mitchell Grice // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +type EnvironmentVersionRange = number | string; + interface IsStatic { //#region Type checks @@ -367,34 +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; - - /** - * Checks if current browser is edge. - */ - edge(): 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. @@ -403,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. @@ -486,6 +502,11 @@ interface IsStatic { */ offline(): boolean; + /** + * Checks if current device supports touch. + */ + touchDevice(): boolean; + //#endregion //#region Time checks diff --git a/types/is/is-tests.ts b/types/is/is-tests.ts index b710bd0db0..6f27fd4b7b 100644 --- a/types/is/is-tests.ts +++ b/types/is/is-tests.ts @@ -446,35 +446,67 @@ is.all.sorted([[1, 2], [5, 4]]); //#region Environment checks is.ie(); -is.ie(6); is.not.ie(); - -is.edge(); -is.not.edge(); +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(); @@ -486,7 +518,6 @@ is.androidTablet(); is.not.androidTablet(); is.blackberry(); - is.not.blackberry(); is.windowsPhone(); @@ -519,6 +550,9 @@ is.not.online(); is.offline(); is.not.offline(); +is.touchDevice(); +is.not.touchDevice(); + //#endregion //#region Time checks