Travis build: 1831

This commit is contained in:
30secondsofcode
2018-03-19 14:51:39 +00:00
parent a0c20dc503
commit 98abde9915
3 changed files with 34 additions and 4 deletions

View File

@ -444,6 +444,7 @@ average(1, 2, 3);
* [`hexToRGB`](#hextorgb-) * [`hexToRGB`](#hextorgb-)
* [`httpGet`](#httpget) * [`httpGet`](#httpget)
* [`httpPost`](#httppost) * [`httpPost`](#httppost)
* [`isBrowser`](#isbrowser)
* [`mostPerformant`](#mostperformant) * [`mostPerformant`](#mostperformant)
* [`nthArg`](#ntharg) * [`nthArg`](#ntharg)
* [`parseCookie`](#parsecookie) * [`parseCookie`](#parsecookie)
@ -8257,6 +8258,32 @@ Logs: {
<br>[⬆ Back to top](#table-of-contents) <br>[⬆ Back to top](#table-of-contents)
### isBrowser
Determines if the current runtime environment is a browser so that front-end modules can run on the server (Node)
without throwing errors.
Use `Array.includes()` on the `typeof` values of both `window` and `document` (globals usually only available in a
browser environment unless they were explicitly defined), which will return `true` if one of them is `undefined`.
`typeof` allows globals to be checked for existence without throwing a ReferenceError. If both of them are not `undefined`, then the current environment is assumed to be a browser.
```js
const isBrowser = () => ![typeof window, typeof document].includes('undefined');
```
<details>
<summary>Examples</summary>
```js
isBrowser(); // true (browser)
isBrowser(); // false (Node)
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### mostPerformant ### mostPerformant
Returns the index of the function in an array of functions which executed the fastest. Returns the index of the function in an array of functions which executed the fastest.

File diff suppressed because one or more lines are too long

View File

@ -8,10 +8,10 @@ browser environment unless they were explicitly defined), which will return `tru
`typeof` allows globals to be checked for existence without throwing a ReferenceError. If both of them are not `undefined`, then the current environment is assumed to be a browser. `typeof` allows globals to be checked for existence without throwing a ReferenceError. If both of them are not `undefined`, then the current environment is assumed to be a browser.
```js ```js
const isBrowser = () => ![typeof window, typeof document].includes('undefined') const isBrowser = () => ![typeof window, typeof document].includes('undefined');
``` ```
```js ```js
isBrowser() // true (browser) isBrowser(); // true (browser)
isBrowser() // false (Node) isBrowser(); // false (Node)
``` ```