-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* replace is_js
- Loading branch information
Showing
8 changed files
with
52 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// utils.ts | ||
import { detect } from "detect-browser"; | ||
|
||
let comparatorFn = { | ||
'<': function(a, b) { return a < b; }, | ||
'<=': function(a, b) { return a <= b; }, | ||
'>': function(a, b) { return a > b; }, | ||
'>=': function(a, b) { return a >= b; } | ||
}; | ||
|
||
export function isBoolean(value: any): boolean { | ||
return typeof value === 'boolean'; | ||
} | ||
|
||
export function isNumber(value: any): boolean { | ||
return typeof value === 'number'; | ||
} | ||
|
||
export function isIE(): boolean { | ||
const browser = detect(); | ||
return browser.name == 'ie'; | ||
} | ||
|
||
export function isSafari(compRange): boolean { | ||
function compare(version, comp) { | ||
let str = (comp + ''); | ||
let n = +(/\d+/.exec(str) || NaN); | ||
let op = /^[<>]=?/.exec(str)[0]; | ||
return comparatorFn[op] ? comparatorFn[op](version, n) : (version == n || Number.isNaN(n)); | ||
} | ||
|
||
const browser = detect(); | ||
return browser.name == 'safari' && compare(browser.version.split('.')[0], compRange); | ||
} |