|
1 | 1 | import slugify from 'slugify';
|
2 | 2 |
|
3 |
| -// so it doesn't throw if no window |
4 |
| -const win = |
5 |
| - typeof window !== 'undefined' ? window : { screen: {}, navigator: {} }; |
6 |
| - |
7 |
| -// passive events test |
8 |
| -// adapted from https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md |
9 |
| -let passiveOptionAccessed = false; |
10 |
| -const options = { |
11 |
| - get passive() { |
12 |
| - return (passiveOptionAccessed = true); |
13 |
| - } |
14 |
| -}; |
15 |
| - |
16 |
| -// have to set and remove a no-op listener instead of null |
17 |
| -// (which was used previously), because Edge v15 throws an error |
18 |
| -// when providing a null callback. |
19 |
| -// https://github.com/rafgraph/detect-passive-events/pull/3 |
20 |
| -const noop = () => {}; |
21 |
| -win.addEventListener && win.addEventListener('p', noop, options); |
22 |
| -win.removeEventListener && win.removeEventListener('p', noop, false); |
23 |
| - |
24 |
| -export const supportsPassiveEvents = passiveOptionAccessed; |
25 |
| - |
26 |
| -export const passiveEventArg = supportsPassiveEvents |
27 |
| - ? { capture: false, passive: true } |
28 |
| - : false; |
29 |
| - |
30 | 3 | export const stringValueOrAll = (str) => {
|
31 | 4 | return typeof str === 'string' && str !== '' ? str : 'all';
|
32 | 5 | };
|
@@ -70,16 +43,8 @@ export const shuffleCopy = (array) => {
|
70 | 43 | return copy;
|
71 | 44 | };
|
72 | 45 |
|
73 |
| -export const randomElement = (array) => { |
74 |
| - if (array.length === 0) { |
75 |
| - return null; |
76 |
| - } |
77 |
| - const index = Math.floor(Math.random() * array.length); |
78 |
| - return array[index]; |
79 |
| -}; |
80 |
| - |
81 | 46 | /**
|
82 |
| - * Creates a URL hash value (fragment) refering to a specific part of a |
| 47 | + * Creates a URL hash value (fragment) referring to a specific part of a |
83 | 48 | * multi-part coding challenge. Part 1 of a challenge has no hash value.
|
84 | 49 | *
|
85 | 50 | * @param partIndex {number} Zero-based part index
|
|
0 commit comments