@taskcluster/client-web 100.4.0 → 101.0.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/index.js CHANGED
@@ -1,27 +1,27 @@
1
- export { default as Client } from './Client';
1
+ export { default as Client } from './Client.js';
2
2
  export {
3
3
  createTemporaryCredentials,
4
4
  credentialInformation,
5
- } from './credentials';
6
- export { fromNow, fromNowJSON, slugid, nice, v4, parseTime } from './utils';
7
- export { default as request } from './fetch';
5
+ } from './credentials.js';
6
+ export { fromNow, fromNowJSON, slugid, nice, v4, parseTime } from './utils.js';
7
+ export { default as request } from './fetch.js';
8
8
 
9
9
  // AUTOGENERATED-START
10
- export { default as Auth } from './clients/Auth';
11
- export { default as AuthEvents } from './clients/AuthEvents';
12
- export { default as Github } from './clients/Github';
13
- export { default as GithubEvents } from './clients/GithubEvents';
14
- export { default as Hooks } from './clients/Hooks';
15
- export { default as HooksEvents } from './clients/HooksEvents';
16
- export { default as Index } from './clients/Index';
17
- export { default as Notify } from './clients/Notify';
18
- export { default as NotifyEvents } from './clients/NotifyEvents';
19
- export { default as Object } from './clients/Object';
20
- export { default as PurgeCache } from './clients/PurgeCache';
21
- export { default as Queue } from './clients/Queue';
22
- export { default as QueueEvents } from './clients/QueueEvents';
23
- export { default as Secrets } from './clients/Secrets';
24
- export { default as WebServer } from './clients/WebServer';
25
- export { default as WorkerManager } from './clients/WorkerManager';
26
- export { default as WorkerManagerEvents } from './clients/WorkerManagerEvents';
10
+ export { default as Auth } from './clients/Auth.js';
11
+ export { default as AuthEvents } from './clients/AuthEvents.js';
12
+ export { default as Github } from './clients/Github.js';
13
+ export { default as GithubEvents } from './clients/GithubEvents.js';
14
+ export { default as Hooks } from './clients/Hooks.js';
15
+ export { default as HooksEvents } from './clients/HooksEvents.js';
16
+ export { default as Index } from './clients/Index.js';
17
+ export { default as Notify } from './clients/Notify.js';
18
+ export { default as NotifyEvents } from './clients/NotifyEvents.js';
19
+ export { default as Object } from './clients/Object.js';
20
+ export { default as PurgeCache } from './clients/PurgeCache.js';
21
+ export { default as Queue } from './clients/Queue.js';
22
+ export { default as QueueEvents } from './clients/QueueEvents.js';
23
+ export { default as Secrets } from './clients/Secrets.js';
24
+ export { default as WebServer } from './clients/WebServer.js';
25
+ export { default as WorkerManager } from './clients/WorkerManager.js';
26
+ export { default as WorkerManagerEvents } from './clients/WorkerManagerEvents.js';
27
27
  // AUTOGENERATED-END
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