@taskcluster/client-web 100.3.0 → 100.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/fetch.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import hawk from 'hawk';
2
2
 
3
- /* eslint-disable-next-line max-len */
4
3
  const JSON_CONTENT = /^(application\/(json|x-javascript)|text\/(x-)?javascript|x-json)(;.*)?$/;
5
4
  const defaults = {
6
5
  credentials: 'omit',
@@ -15,26 +14,19 @@ const defaults = {
15
14
  };
16
15
  const handleResponse = response =>
17
16
  Promise.resolve(response)
18
- .then(
19
- () =>
20
- JSON_CONTENT.test(response.headers.get('Content-Type'))
21
- ? response.json()
22
- : null,
23
- )
17
+ .then(() => (JSON_CONTENT.test(response.headers.get('Content-Type')) ? response.json() : null))
24
18
  .then(json => {
25
19
  if (response.ok) {
26
20
  return json;
27
21
  }
28
22
 
29
- const message = json.message
30
- ? json.message.split('---')[0]
31
- : response.statusText;
23
+ const message = json.message ? json.message.split('---')[0] : response.statusText;
32
24
 
33
25
  return Promise.reject(
34
26
  Object.assign(new Error(message), {
35
27
  response,
36
28
  body: json,
37
- }),
29
+ })
38
30
  );
39
31
  });
40
32
 
@@ -62,7 +54,7 @@ export default (url, opts = {}) => {
62
54
 
63
55
  // do not follow redirects
64
56
  // https://developer.mozilla.org/en-US/docs/Web/API/Response/redirected#Disallowing_redirects
65
- options.redirect = "error";
57
+ options.redirect = 'error';
66
58
 
67
59
  return new Promise((resolve, reject) => {
68
60
  (function attempt(n) {
@@ -77,12 +69,8 @@ export default (url, opts = {}) => {
77
69
  reject(err);
78
70
  } else {
79
71
  const delay = Math.min(
80
- (n - 1) ** 2 *
81
- delayFactor *
82
- (Math.random() * 2 * randomizationFactor +
83
- 1 -
84
- randomizationFactor),
85
- maxDelay,
72
+ (n - 1) ** 2 * delayFactor * (Math.random() * 2 * randomizationFactor + 1 - randomizationFactor),
73
+ maxDelay
86
74
  );
87
75
 
88
76
  setTimeout(() => attempt(n + 1), delay);
package/src/utils.js CHANGED
@@ -12,7 +12,7 @@ const timeExpression = new RegExp(
12
12
  '(\\s*(\\d+)\\s*s(ec(onds?)?)?)?',
13
13
  '\\s*$',
14
14
  ].join(''),
15
- 'i',
15
+ 'i'
16
16
  );
17
17
 
18
18
  export const parseTime = (str = '') => {
@@ -59,7 +59,7 @@ export const fromNow = (offset, reference = new Date()) => {
59
59
  parsedOffset.days * 24 * 60 * 60 * 1000 +
60
60
  parsedOffset.hours * 60 * 60 * 1000 +
61
61
  parsedOffset.minutes * 60 * 1000 +
62
- parsedOffset.seconds * 1000,
62
+ parsedOffset.seconds * 1000
63
63
  );
64
64
  };
65
65
 
@@ -76,10 +76,8 @@ export const fromNow = (offset, reference = new Date()) => {
76
76
  * short hand `1d2h3min`, it's fairly tolerant of different spelling forms and
77
77
  * whitespace. But only really meant to be used with constants.
78
78
  */
79
- export const fromNowJSON = (offset, reference) =>
80
- fromNow(offset, reference).toJSON();
79
+ export const fromNowJSON = (offset, reference) => fromNow(offset, reference).toJSON();
81
80
 
82
- /* eslint-disable no-bitwise, no-mixed-operators */
83
81
  export const uuid = () => {
84
82
  const randoms = crypto.getRandomValues(new Uint8Array(16));
85
83
 
@@ -101,7 +99,6 @@ const slug = (nice = false) => {
101
99
  .replace(/\//g, '_') // Replace / with _ (see RFC 4648, sec. 5)
102
100
  .substring(0, 22); // Drop '==' padding
103
101
  };
104
- /* eslint-enable no-bitwise, no-mixed-operators */
105
102
 
106
103
  /**
107
104
  * Returns a randomly generated uuid v4 compliant slug