@reykjavik/webtools 0.2.10 → 0.3.1

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/CHANGELOG.md CHANGED
@@ -4,14 +4,23 @@
4
4
 
5
5
  - ... <!-- Add new lines here. -->
6
6
 
7
- ## 0.2.10
7
+ ## 0.3.1
8
8
 
9
- _2025-09-30_
9
+ _2025-11-10_
10
10
 
11
- - `@reykjavik/webtools/next/vanillaExtract`:
12
- - fix: Remove stray side-effect invocation of `vanillaClass` on import
11
+ - docs: Update JSDoc @see links to point to new version branch
12
+
13
+ ## 0.3.0
14
+
15
+ _2025-11-10_
16
+
17
+ - `@reykjavik/webtools/http`:
18
+ - **BREAKING** feat: `toMs()` now treats raw numbers as milliseconds (not as
19
+ seconds)
20
+ - `@reykjavik/webtools/errorhandling`:
21
+ - feat: Alias `Result.catch()` as `Result.ify()` for readability
13
22
 
14
- ## 0.2.9
23
+ ## 0.2.9 – 0.2.10
15
24
 
16
25
  _2025-09-30_
17
26
 
@@ -220,14 +220,14 @@ export type CookieHubProviderProps = EitherObj<{
220
220
  * management script and sets up a React state object with the relevant user
221
221
  * consent flags.
222
222
  *
223
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cookiehubprovider-component
223
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cookiehubprovider-component
224
224
  */
225
225
  export declare const CookieHubProvider: (props: CookieHubProviderProps) => React.JSX.Element;
226
226
  /**
227
227
  * Returns up-to-date cookie consent flags. For use in React components or hook
228
228
  * functions.
229
229
  *
230
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#usecookiehubconsent
230
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usecookiehubconsent
231
231
  */
232
232
  export declare const useCookieHubConsent: () => Partial<CookieHubContextState["consent"]>;
233
233
  export {};
@@ -71,7 +71,7 @@ const moveCookiehubScriptInDomTree = () => {
71
71
  * management script and sets up a React state object with the relevant user
72
72
  * consent flags.
73
73
  *
74
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cookiehubprovider-component
74
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cookiehubprovider-component
75
75
  */
76
76
  const CookieHubProvider = (props) => {
77
77
  const [state, setState] = (0, react_1.useState)(initialConsentState);
@@ -159,7 +159,7 @@ exports.CookieHubProvider = CookieHubProvider;
159
159
  * Returns up-to-date cookie consent flags. For use in React components or hook
160
160
  * functions.
161
161
  *
162
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#usecookiehubconsent
162
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usecookiehubconsent
163
163
  */
164
164
  const useCookieHubConsent = () => { var _a; return ((_a = (0, react_1.useContext)(CookieHubContext)) === null || _a === void 0 ? void 0 : _a.consent) || {}; };
165
165
  exports.useCookieHubConsent = useCookieHubConsent;
package/README.md CHANGED
@@ -41,6 +41,7 @@ bun add @reykjavik/webtools
41
41
  - [Type `ResultTupleObj`](#type-resulttupleobj)
42
42
  - [Type `ResultTupleObj.mapTo`](#type-resulttupleobjmapto)
43
43
  - [`Result.catch`](#resultcatch)
44
+ - [`Result.ify`](#resultify)
44
45
  - [`Result.map`](#resultmap)
45
46
  - [`Result.Success`](#resultsuccess)
46
47
  - [`Result.Fail`](#resultfail)
@@ -230,7 +231,11 @@ import type { toSec, TTL } from '@reykjavik/webtools/http';
230
231
 
231
232
  const ttl: TTL = '2h';
232
233
 
233
- const ttlSec = toSec(ttl);
234
+ const ttlSec1 = toSec(ttl); // 7200
235
+ // Raw numbers are returned as-is (rounded)
236
+ const ttlSec2 = toSec(10.6); // 11
237
+ // Negative numbers become zero
238
+ const ttlSec3 = toSec('-1h'); // 0
234
239
  ```
235
240
 
236
241
  ### `toMs` duration helper
@@ -246,7 +251,11 @@ import type { toMs, TTL } from '@reykjavik/webtools/http';
246
251
 
247
252
  const ttl: TTL = '2h';
248
253
 
249
- const ttlSec = toMs(ttl);
254
+ const ttlMs1 = toMs(ttl); // 7_200_000
255
+ // Raw numbers are returned as-is (rounded)
256
+ const ttlMs2 = toMs(499.9); // 500
257
+ // Negative numbers become zero
258
+ const ttlMs3 = toMs('-1h'); // 0
250
259
  ```
251
260
 
252
261
  ---
@@ -711,6 +720,8 @@ failed `ResultTupleObj`.
711
720
 
712
721
  ### `Result.catch`
713
722
 
723
+ Aliased as `Result.ify` for readability.
724
+
714
725
  **Syntax:**
715
726
  `Result.catch<T, Err>(callback: () => T): ResultTupleObj<T, Err>`
716
727
  **Syntax:**
@@ -744,14 +755,19 @@ fooQuery.result; // Guaranteed to be defined
744
755
 
745
756
  This function acts as the inverse of [`Result.throw()`](#resultthrow).
746
757
 
758
+ ### `Result.ify`
759
+
760
+ Syntatic sugar alias of [`Result.catch`](#resultcatch).
761
+
747
762
  ### `Result.map`
748
763
 
749
764
  **Syntax:**
750
765
  `Result.map<T, T2, E>(result: ResultTuple<T, E>, mapResult: (resultValue: T) => T2): ResultTuple<T2, E>`
751
766
 
752
- Helper to map a `ResultTuple`-like object to a new `ResultTupleObj` object,
753
- applying a transformation function to the result, but retaining the error
754
- as-is.
767
+ Convenience helper to map a `ResultTuple`-like object to a new
768
+ `ResultTupleObj` object, applying a transformation function to the result, but
769
+ retaining the error as-is. Errors thrown from the mapping function are caught
770
+ and turned into a failed `ResultTupleObj`.
755
771
 
756
772
  ```ts
757
773
  import { Result } from '@reykjavik/webtools/errorhandling';
package/SiteImprove.d.ts CHANGED
@@ -45,14 +45,14 @@ type SiteImproveCustomEvent = [
45
45
  /**
46
46
  * A small helper for tracking custom UI events and reporting them to SiteImrove.
47
47
  *
48
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#pingsiteimprove-helper
48
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimprove-helper
49
49
  */
50
50
  export declare const pingSiteImprove: (category: string, action: string, label?: string) => void;
51
51
  /**
52
52
  * A small helper for reporting to SiteImrove when the user is programmatically
53
53
  * being sent to a different URL/resource.
54
54
  *
55
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#pingsiteimproveoutbound-helper
55
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimproveoutbound-helper
56
56
  */
57
57
  export declare const pingSiteImproveOutbound: (ourl: string) => void;
58
58
  export type SiteImproveProps = EitherObj<{
@@ -94,7 +94,7 @@ export type SiteImproveProps = EitherObj<{
94
94
  * A component for loading a SiteImprove analytics script and set up page-view
95
95
  * tracking across client-side (pushState, replaceState) routing.
96
96
  *
97
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#siteimprove-component
97
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#siteimprove-component
98
98
  */
99
99
  export declare const SiteImprove: (props: SiteImproveProps) => null;
100
100
  export {};
package/SiteImprove.js CHANGED
@@ -29,7 +29,7 @@ const trackDynamicPageView = (url, refUrl, title) => _emitEvent(['trackdynamic',
29
29
  /**
30
30
  * A small helper for tracking custom UI events and reporting them to SiteImrove.
31
31
  *
32
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#pingsiteimprove-helper
32
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimprove-helper
33
33
  */
34
34
  const pingSiteImprove = (category, action, label) => {
35
35
  if (process.env.NODE_ENV === 'development' &&
@@ -44,7 +44,7 @@ exports.pingSiteImprove = pingSiteImprove;
44
44
  * A small helper for reporting to SiteImrove when the user is programmatically
45
45
  * being sent to a different URL/resource.
46
46
  *
47
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#pingsiteimproveoutbound-helper
47
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimproveoutbound-helper
48
48
  */
49
49
  const pingSiteImproveOutbound = (ourl) => {
50
50
  if (process.env.NODE_ENV === 'development' &&
@@ -125,7 +125,7 @@ const loc = typeof document !== 'undefined' ? document.location : {};
125
125
  * A component for loading a SiteImprove analytics script and set up page-view
126
126
  * tracking across client-side (pushState, replaceState) routing.
127
127
  *
128
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#siteimprove-component
128
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#siteimprove-component
129
129
  */
130
130
  const SiteImprove = (props) => {
131
131
  const consented = useResolvedAnalyticsConsent(props.hasConsented);
package/async.d.ts CHANGED
@@ -18,7 +18,7 @@ export declare const addLag: (length: number, opts?: {
18
18
  * Resolves as soon as all of the passed `promises` have resolved/settled,
19
19
  * or after `timeout` milliseconds — whichever comes first.
20
20
  *
21
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#maxwait
21
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#maxwait
22
22
  */
23
23
  export declare function maxWait(timeout: number, promises: Array<unknown>): Promise<void>;
24
24
  export declare function maxWait<PromiseMap extends PlainObj>(timeout: number, promises: PromiseMap): Promise<{
@@ -28,7 +28,7 @@ export declare function maxWait<PromiseMap extends PlainObj>(timeout: number, pr
28
28
  * A variation of `Promise.all()` that accepts an object with named promises
29
29
  * and returns a same-shaped object with the resolved values.
30
30
  *
31
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#promiseallobject
31
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#promiseallobject
32
32
  */
33
33
  export declare const promiseAllObject: <T extends PlainObj>(promisesMap: T) => Promise<{ -readonly [K in keyof T]: Awaited<T[K]>; }>;
34
34
  type Cancellable<A extends Array<unknown>> = ((...args: A) => void) & {
@@ -44,7 +44,7 @@ type Cancellable<A extends Array<unknown>> = ((...args: A) => void) & {
44
44
  * of quiet-time. \
45
45
  * The returned function also has a nice `.cancel()` method.
46
46
  *
47
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#debounce
47
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#debounce
48
48
  */
49
49
  export declare const debounce: {
50
50
  <A extends Array<unknown>>(func: (...args: A) => void, delay: number, immediate?: boolean): Cancellable<A>;
@@ -64,7 +64,7 @@ type Finishable<A extends Array<unknown>> = ((...args: A) => void) & {
64
64
  * The returned function also has a nice `.finish()` method to reset the
65
65
  * throttle timer
66
66
  *
67
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#throttle
67
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#throttle
68
68
  */
69
69
  export declare const throttle: {
70
70
  <A extends Array<unknown>>(func: (...args: A) => void, delay: number, skipFirst?: boolean): Finishable<A>;
package/async.js CHANGED
@@ -67,7 +67,7 @@ function maxWait(timeout, promises) {
67
67
  * A variation of `Promise.all()` that accepts an object with named promises
68
68
  * and returns a same-shaped object with the resolved values.
69
69
  *
70
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#promiseallobject
70
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#promiseallobject
71
71
  */
72
72
  /*#__NO_SIDE_EFFECTS__*/
73
73
  const promiseAllObject = (promisesMap) => Promise.all(Object.values(promisesMap)).then((results) => {
@@ -84,7 +84,7 @@ exports.promiseAllObject = promiseAllObject;
84
84
  * of quiet-time. \
85
85
  * The returned function also has a nice `.cancel()` method.
86
86
  *
87
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#debounce
87
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#debounce
88
88
  */
89
89
  /*#__NO_SIDE_EFFECTS__*/
90
90
  const debounce = (
@@ -136,7 +136,7 @@ exports.debounce.d = (delay, immediate) => (0, exports.debounce)(function (fn, .
136
136
  * The returned function also has a nice `.finish()` method to reset the
137
137
  * throttle timer
138
138
  *
139
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#throttle
139
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#throttle
140
140
  */
141
141
  /*#__NO_SIDE_EFFECTS__*/
142
142
  const throttle = (
@@ -2,7 +2,7 @@
2
2
  * Error subclass for thrown NON-Error values that got turned into an actual
3
3
  * Error, with the original thrown value as the `payload` property.
4
4
  *
5
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
5
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
6
6
  */
7
7
  export declare class ErrorFromPayload extends Error {
8
8
  /**
@@ -25,7 +25,7 @@ export declare class ErrorFromPayload extends Error {
25
25
  * something else it is wrapped in a new `ErrorFromPayload` instance, and the
26
26
  * original value is stored in a `payload`
27
27
  *
28
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
28
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
29
29
  */
30
30
  export declare const asError: (maybeError: unknown) => ErrorFromPayload;
31
31
  type SuccessResult<T> = [error: undefined, result: T] & {
@@ -41,14 +41,14 @@ type FailResult<E extends Error> = [error: E, result?: undefined] & {
41
41
  /**
42
42
  * Simple bare-bones discriminated tuple type for a [error, result] pair.
43
43
  *
44
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#type-resulttuple
44
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#type-resulttuple
45
45
  */
46
46
  export type ResultTuple<T, E extends Error = Error> = [error: undefined, result: T] | [error: E, result?: undefined];
47
47
  /**
48
48
  * Discriminated tuple type for a `[error, result]` pair (same as `ResultTuple`)
49
49
  * but with named properties `error` and `result` attached for dev convenience.
50
50
  *
51
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#type-resulttupleobj
51
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#type-resulttupleobj
52
52
  */
53
53
  export type ResultTupleObj<T, E extends Error = Error> = SuccessResult<T> | FailResult<E>;
54
54
  /**
@@ -60,7 +60,7 @@ export type ResultTupleObj<T, E extends Error = Error> = SuccessResult<T> | Fail
60
60
  *
61
61
  * Works on both promises and (synchronous) callback functions.
62
62
  *
63
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultcatch
63
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultcatch
64
64
  */
65
65
  declare function catch_<T, E extends Error = ErrorFromPayload>(promise: Promise<T>): Promise<ResultTupleObj<T, E>>;
66
66
  declare function catch_<T, E extends Error = ErrorFromPayload>(callback: () => T): ResultTupleObj<T, E>;
@@ -68,35 +68,36 @@ declare function catch_<T, E extends Error = ErrorFromPayload>(callback: () => T
68
68
  * Singleton object with small methods for creating, mapping or handling
69
69
  * `ResultTupleObj` instances.
70
70
  *
71
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#result-singleton
71
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#result-singleton
72
72
  */
73
73
  export declare const Result: {
74
74
  /**
75
75
  * Factory for creating a successful `Result.TupleObj`.
76
76
  *
77
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultsuccess
77
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsuccess
78
78
  */
79
79
  Success: <T>(result: T) => SuccessResult<T>;
80
80
  /**
81
81
  * Factory for creating a failed `Result.TupleObj`.
82
82
  *
83
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultsfail
83
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsfail
84
84
  */
85
85
  Fail: <E extends Error = Error>(e: unknown) => FailResult<E>;
86
86
  catch: typeof catch_;
87
+ ify: typeof catch_;
87
88
  /**
88
89
  * Helper to map a `ResultTuple`-like object to a new `ResultTupleObj`
89
90
  * object, applying a transformation function to the result, but retaining
90
91
  * the error as-is.
91
92
  *
92
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulmap
93
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulmap
93
94
  */
94
95
  map: <T, T2, E extends Error>(result: ResultTuple<T, E>, mapFn: (resultValue: T) => T2) => ResultTupleObj<T2, E>;
95
96
  /**
96
97
  * Unwraps a discriminated [error, result] `Result.Tuple`-like object
97
98
  * and throws if there's an error, but returns the result otherwise.
98
99
  *
99
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulthrow
100
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulthrow
100
101
  */
101
102
  throw: <T>(result: ResultTuple<T>) => T;
102
103
  };
package/errorhandling.js CHANGED
@@ -5,7 +5,7 @@ exports.Result = exports.asError = exports.ErrorFromPayload = void 0;
5
5
  * Error subclass for thrown NON-Error values that got turned into an actual
6
6
  * Error, with the original thrown value as the `payload` property.
7
7
  *
8
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
8
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
9
9
  */
10
10
  /*#__NO_SIDE_EFFECTS__*/
11
11
  class ErrorFromPayload extends Error {
@@ -28,7 +28,7 @@ exports.ErrorFromPayload = ErrorFromPayload;
28
28
  * something else it is wrapped in a new `ErrorFromPayload` instance, and the
29
29
  * original value is stored in a `payload`
30
30
  *
31
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
31
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
32
32
  */
33
33
  /*#__NO_SIDE_EFFECTS__*/
34
34
  const asError = (maybeError) => {
@@ -79,29 +79,30 @@ mapFn) => {
79
79
  * Singleton object with small methods for creating, mapping or handling
80
80
  * `ResultTupleObj` instances.
81
81
  *
82
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#result-singleton
82
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#result-singleton
83
83
  */
84
84
  exports.Result = {
85
85
  /**
86
86
  * Factory for creating a successful `Result.TupleObj`.
87
87
  *
88
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultsuccess
88
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsuccess
89
89
  */
90
90
  Success,
91
91
  /**
92
92
  * Factory for creating a failed `Result.TupleObj`.
93
93
  *
94
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultsfail
94
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsfail
95
95
  */
96
96
  Fail,
97
97
  // NOTE: The JSDoc must be placed above the `catch_` function above.
98
98
  catch: catch_,
99
+ ify: catch_,
99
100
  /**
100
101
  * Helper to map a `ResultTuple`-like object to a new `ResultTupleObj`
101
102
  * object, applying a transformation function to the result, but retaining
102
103
  * the error as-is.
103
104
  *
104
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulmap
105
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulmap
105
106
  */
106
107
  /*#__NO_SIDE_EFFECTS__*/
107
108
  map: (result, mapFn) => {
@@ -115,7 +116,7 @@ exports.Result = {
115
116
  * Unwraps a discriminated [error, result] `Result.Tuple`-like object
116
117
  * and throws if there's an error, but returns the result otherwise.
117
118
  *
118
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulthrow
119
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulthrow
119
120
  */
120
121
  /*#__NO_SIDE_EFFECTS__*/
121
122
  throw: (result) => {
@@ -220,14 +220,14 @@ export type CookieHubProviderProps = EitherObj<{
220
220
  * management script and sets up a React state object with the relevant user
221
221
  * consent flags.
222
222
  *
223
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cookiehubprovider-component
223
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cookiehubprovider-component
224
224
  */
225
225
  export declare const CookieHubProvider: (props: CookieHubProviderProps) => React.JSX.Element;
226
226
  /**
227
227
  * Returns up-to-date cookie consent flags. For use in React components or hook
228
228
  * functions.
229
229
  *
230
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#usecookiehubconsent
230
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usecookiehubconsent
231
231
  */
232
232
  export declare const useCookieHubConsent: () => Partial<CookieHubContextState["consent"]>;
233
233
  export {};
@@ -35,7 +35,7 @@ const moveCookiehubScriptInDomTree = () => {
35
35
  * management script and sets up a React state object with the relevant user
36
36
  * consent flags.
37
37
  *
38
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#cookiehubprovider-component
38
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#cookiehubprovider-component
39
39
  */
40
40
  export const CookieHubProvider = (props) => {
41
41
  const [state, setState] = useState(initialConsentState);
@@ -122,6 +122,6 @@ export const CookieHubProvider = (props) => {
122
122
  * Returns up-to-date cookie consent flags. For use in React components or hook
123
123
  * functions.
124
124
  *
125
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#usecookiehubconsent
125
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#usecookiehubconsent
126
126
  */
127
127
  export const useCookieHubConsent = () => { var _a; return ((_a = useContext(CookieHubContext)) === null || _a === void 0 ? void 0 : _a.consent) || {}; };
@@ -45,14 +45,14 @@ type SiteImproveCustomEvent = [
45
45
  /**
46
46
  * A small helper for tracking custom UI events and reporting them to SiteImrove.
47
47
  *
48
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#pingsiteimprove-helper
48
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimprove-helper
49
49
  */
50
50
  export declare const pingSiteImprove: (category: string, action: string, label?: string) => void;
51
51
  /**
52
52
  * A small helper for reporting to SiteImrove when the user is programmatically
53
53
  * being sent to a different URL/resource.
54
54
  *
55
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#pingsiteimproveoutbound-helper
55
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimproveoutbound-helper
56
56
  */
57
57
  export declare const pingSiteImproveOutbound: (ourl: string) => void;
58
58
  export type SiteImproveProps = EitherObj<{
@@ -94,7 +94,7 @@ export type SiteImproveProps = EitherObj<{
94
94
  * A component for loading a SiteImprove analytics script and set up page-view
95
95
  * tracking across client-side (pushState, replaceState) routing.
96
96
  *
97
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#siteimprove-component
97
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#siteimprove-component
98
98
  */
99
99
  export declare const SiteImprove: (props: SiteImproveProps) => null;
100
100
  export {};
@@ -26,7 +26,7 @@ const trackDynamicPageView = (url, refUrl, title) => _emitEvent(['trackdynamic',
26
26
  /**
27
27
  * A small helper for tracking custom UI events and reporting them to SiteImrove.
28
28
  *
29
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#pingsiteimprove-helper
29
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimprove-helper
30
30
  */
31
31
  export const pingSiteImprove = (category, action, label) => {
32
32
  if (process.env.NODE_ENV === 'development' &&
@@ -40,7 +40,7 @@ export const pingSiteImprove = (category, action, label) => {
40
40
  * A small helper for reporting to SiteImrove when the user is programmatically
41
41
  * being sent to a different URL/resource.
42
42
  *
43
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#pingsiteimproveoutbound-helper
43
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#pingsiteimproveoutbound-helper
44
44
  */
45
45
  export const pingSiteImproveOutbound = (ourl) => {
46
46
  if (process.env.NODE_ENV === 'development' &&
@@ -120,7 +120,7 @@ const loc = typeof document !== 'undefined' ? document.location : {};
120
120
  * A component for loading a SiteImprove analytics script and set up page-view
121
121
  * tracking across client-side (pushState, replaceState) routing.
122
122
  *
123
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#siteimprove-component
123
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#siteimprove-component
124
124
  */
125
125
  export const SiteImprove = (props) => {
126
126
  const consented = useResolvedAnalyticsConsent(props.hasConsented);
package/esm/async.d.ts CHANGED
@@ -18,7 +18,7 @@ export declare const addLag: (length: number, opts?: {
18
18
  * Resolves as soon as all of the passed `promises` have resolved/settled,
19
19
  * or after `timeout` milliseconds — whichever comes first.
20
20
  *
21
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#maxwait
21
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#maxwait
22
22
  */
23
23
  export declare function maxWait(timeout: number, promises: Array<unknown>): Promise<void>;
24
24
  export declare function maxWait<PromiseMap extends PlainObj>(timeout: number, promises: PromiseMap): Promise<{
@@ -28,7 +28,7 @@ export declare function maxWait<PromiseMap extends PlainObj>(timeout: number, pr
28
28
  * A variation of `Promise.all()` that accepts an object with named promises
29
29
  * and returns a same-shaped object with the resolved values.
30
30
  *
31
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#promiseallobject
31
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#promiseallobject
32
32
  */
33
33
  export declare const promiseAllObject: <T extends PlainObj>(promisesMap: T) => Promise<{ -readonly [K in keyof T]: Awaited<T[K]>; }>;
34
34
  type Cancellable<A extends Array<unknown>> = ((...args: A) => void) & {
@@ -44,7 +44,7 @@ type Cancellable<A extends Array<unknown>> = ((...args: A) => void) & {
44
44
  * of quiet-time. \
45
45
  * The returned function also has a nice `.cancel()` method.
46
46
  *
47
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#debounce
47
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#debounce
48
48
  */
49
49
  export declare const debounce: {
50
50
  <A extends Array<unknown>>(func: (...args: A) => void, delay: number, immediate?: boolean): Cancellable<A>;
@@ -64,7 +64,7 @@ type Finishable<A extends Array<unknown>> = ((...args: A) => void) & {
64
64
  * The returned function also has a nice `.finish()` method to reset the
65
65
  * throttle timer
66
66
  *
67
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#throttle
67
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#throttle
68
68
  */
69
69
  export declare const throttle: {
70
70
  <A extends Array<unknown>>(func: (...args: A) => void, delay: number, skipFirst?: boolean): Finishable<A>;
package/esm/async.js CHANGED
@@ -61,7 +61,7 @@ export function maxWait(timeout, promises) {
61
61
  * A variation of `Promise.all()` that accepts an object with named promises
62
62
  * and returns a same-shaped object with the resolved values.
63
63
  *
64
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#promiseallobject
64
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#promiseallobject
65
65
  */
66
66
  /*#__NO_SIDE_EFFECTS__*/
67
67
  export const promiseAllObject = (promisesMap) => Promise.all(Object.values(promisesMap)).then((results) => {
@@ -77,7 +77,7 @@ export const promiseAllObject = (promisesMap) => Promise.all(Object.values(promi
77
77
  * of quiet-time. \
78
78
  * The returned function also has a nice `.cancel()` method.
79
79
  *
80
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#debounce
80
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#debounce
81
81
  */
82
82
  /*#__NO_SIDE_EFFECTS__*/
83
83
  export const debounce = (
@@ -128,7 +128,7 @@ debounce.d = (delay, immediate) => debounce(function (fn, ...args) {
128
128
  * The returned function also has a nice `.finish()` method to reset the
129
129
  * throttle timer
130
130
  *
131
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#throttle
131
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#throttle
132
132
  */
133
133
  /*#__NO_SIDE_EFFECTS__*/
134
134
  export const throttle = (
@@ -2,7 +2,7 @@
2
2
  * Error subclass for thrown NON-Error values that got turned into an actual
3
3
  * Error, with the original thrown value as the `payload` property.
4
4
  *
5
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
5
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
6
6
  */
7
7
  export declare class ErrorFromPayload extends Error {
8
8
  /**
@@ -25,7 +25,7 @@ export declare class ErrorFromPayload extends Error {
25
25
  * something else it is wrapped in a new `ErrorFromPayload` instance, and the
26
26
  * original value is stored in a `payload`
27
27
  *
28
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#aserror
28
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#aserror
29
29
  */
30
30
  export declare const asError: (maybeError: unknown) => ErrorFromPayload;
31
31
  type SuccessResult<T> = [error: undefined, result: T] & {
@@ -41,14 +41,14 @@ type FailResult<E extends Error> = [error: E, result?: undefined] & {
41
41
  /**
42
42
  * Simple bare-bones discriminated tuple type for a [error, result] pair.
43
43
  *
44
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#type-resulttuple
44
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#type-resulttuple
45
45
  */
46
46
  export type ResultTuple<T, E extends Error = Error> = [error: undefined, result: T] | [error: E, result?: undefined];
47
47
  /**
48
48
  * Discriminated tuple type for a `[error, result]` pair (same as `ResultTuple`)
49
49
  * but with named properties `error` and `result` attached for dev convenience.
50
50
  *
51
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#type-resulttupleobj
51
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#type-resulttupleobj
52
52
  */
53
53
  export type ResultTupleObj<T, E extends Error = Error> = SuccessResult<T> | FailResult<E>;
54
54
  /**
@@ -60,7 +60,7 @@ export type ResultTupleObj<T, E extends Error = Error> = SuccessResult<T> | Fail
60
60
  *
61
61
  * Works on both promises and (synchronous) callback functions.
62
62
  *
63
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultcatch
63
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultcatch
64
64
  */
65
65
  declare function catch_<T, E extends Error = ErrorFromPayload>(promise: Promise<T>): Promise<ResultTupleObj<T, E>>;
66
66
  declare function catch_<T, E extends Error = ErrorFromPayload>(callback: () => T): ResultTupleObj<T, E>;
@@ -68,35 +68,36 @@ declare function catch_<T, E extends Error = ErrorFromPayload>(callback: () => T
68
68
  * Singleton object with small methods for creating, mapping or handling
69
69
  * `ResultTupleObj` instances.
70
70
  *
71
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#result-singleton
71
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#result-singleton
72
72
  */
73
73
  export declare const Result: {
74
74
  /**
75
75
  * Factory for creating a successful `Result.TupleObj`.
76
76
  *
77
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultsuccess
77
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsuccess
78
78
  */
79
79
  Success: <T>(result: T) => SuccessResult<T>;
80
80
  /**
81
81
  * Factory for creating a failed `Result.TupleObj`.
82
82
  *
83
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resultsfail
83
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resultsfail
84
84
  */
85
85
  Fail: <E extends Error = Error>(e: unknown) => FailResult<E>;
86
86
  catch: typeof catch_;
87
+ ify: typeof catch_;
87
88
  /**
88
89
  * Helper to map a `ResultTuple`-like object to a new `ResultTupleObj`
89
90
  * object, applying a transformation function to the result, but retaining
90
91
  * the error as-is.
91
92
  *
92
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulmap
93
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulmap
93
94
  */
94
95
  map: <T, T2, E extends Error>(result: ResultTuple<T, E>, mapFn: (resultValue: T) => T2) => ResultTupleObj<T2, E>;
95
96
  /**
96
97
  * Unwraps a discriminated [error, result] `Result.Tuple`-like object
97
98
  * and throws if there's an error, but returns the result otherwise.
98
99
  *
99
- * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#resulthrow
100
+ * @see https://github.com/reykjavikcity/webtools/blob/v0.3/README.md#resulthrow
100
101
  */
101
102
  throw: <T>(result: ResultTuple<T>) => T;
102
103
  };