shelving 1.138.0 → 1.139.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.
Files changed (83) hide show
  1. package/db/Provider.js +3 -3
  2. package/error/BaseError.d.ts +3 -1
  3. package/error/index.d.ts +0 -1
  4. package/error/index.js +0 -1
  5. package/markup/rule/link.js +3 -2
  6. package/package.json +1 -1
  7. package/schema/AllowSchema.js +4 -4
  8. package/schema/DateSchema.js +2 -1
  9. package/schema/EntitySchema.js +4 -4
  10. package/schema/NumberSchema.js +3 -2
  11. package/store/ArrayStore.js +5 -5
  12. package/util/array.d.ts +67 -66
  13. package/util/array.js +90 -30
  14. package/util/async.js +4 -4
  15. package/util/base64.d.ts +7 -7
  16. package/util/base64.js +40 -31
  17. package/util/boolean.d.ts +6 -5
  18. package/util/boolean.js +11 -11
  19. package/util/bytes.d.ts +4 -1
  20. package/util/bytes.js +7 -3
  21. package/util/class.js +2 -2
  22. package/util/color.d.ts +4 -3
  23. package/util/color.js +5 -6
  24. package/util/crypto.d.ts +21 -0
  25. package/util/crypto.js +80 -0
  26. package/util/data.d.ts +6 -13
  27. package/util/data.js +8 -12
  28. package/util/date.d.ts +35 -27
  29. package/util/date.js +90 -82
  30. package/util/dictionary.d.ts +13 -7
  31. package/util/dictionary.js +12 -12
  32. package/util/entity.d.ts +8 -7
  33. package/util/entity.js +8 -8
  34. package/util/equal.d.ts +3 -2
  35. package/util/equal.js +5 -5
  36. package/util/file.d.ts +2 -1
  37. package/util/file.js +3 -3
  38. package/util/format.d.ts +51 -0
  39. package/util/format.js +113 -0
  40. package/util/function.js +2 -2
  41. package/util/index.d.ts +2 -0
  42. package/util/index.js +2 -0
  43. package/util/iterate.d.ts +0 -15
  44. package/util/iterate.js +0 -55
  45. package/util/jwt.d.ts +4 -2
  46. package/util/jwt.js +50 -41
  47. package/util/link.d.ts +26 -10
  48. package/util/link.js +34 -21
  49. package/util/map.d.ts +8 -7
  50. package/util/map.js +17 -18
  51. package/util/null.d.ts +7 -6
  52. package/util/null.js +13 -13
  53. package/util/number.d.ts +36 -42
  54. package/util/number.js +60 -82
  55. package/util/object.d.ts +0 -7
  56. package/util/object.js +4 -24
  57. package/util/optional.d.ts +2 -1
  58. package/util/optional.js +2 -2
  59. package/util/path.d.ts +7 -6
  60. package/util/path.js +10 -10
  61. package/util/query.js +3 -3
  62. package/util/random.js +2 -2
  63. package/util/regexp.js +2 -2
  64. package/util/set.d.ts +7 -6
  65. package/util/set.js +13 -13
  66. package/util/string.d.ts +26 -37
  67. package/util/string.js +40 -69
  68. package/util/template.d.ts +5 -4
  69. package/util/template.js +14 -13
  70. package/util/time.d.ts +7 -8
  71. package/util/time.js +14 -21
  72. package/util/transform.d.ts +3 -2
  73. package/util/transform.js +0 -1
  74. package/util/undefined.d.ts +4 -3
  75. package/util/undefined.js +8 -6
  76. package/util/units.d.ts +1 -2
  77. package/util/units.js +1 -1
  78. package/util/update.js +3 -3
  79. package/util/url.d.ts +6 -7
  80. package/util/url.js +7 -17
  81. package/util/validate.d.ts +2 -2
  82. package/error/AssertionError.d.ts +0 -8
  83. package/error/AssertionError.js +0 -12
package/util/url.d.ts CHANGED
@@ -1,13 +1,12 @@
1
+ import type { AnyCaller } from "../error/BaseError.js";
1
2
  import { type Optional } from "./optional.js";
2
- /** Things that can be converted to a URL instance. */
3
+ /** Values that can be converted to a URL instance. */
3
4
  export type PossibleURL = string | URL;
4
5
  /** Is an unknown value a URL object? */
5
6
  export declare function isURL(value: unknown): value is URL;
6
7
  /** Assert that an unknown value is a URL object. */
7
- export declare function assertURL(value: unknown): asserts value is URL;
8
+ export declare function assertURL(value: unknown, caller?: AnyCaller): asserts value is URL;
8
9
  /** Convert a possible URL to a URL, or return `undefined` if conversion fails. */
9
- export declare function getOptionalURL(possible: Optional<PossibleURL>, base?: PossibleURL | undefined): URL | undefined;
10
- /** Convert a possible URL to a URL, or throw `AssertionError` if conversion fails. */
11
- export declare function requireURL(possible: PossibleURL, base?: PossibleURL): URL;
12
- /** Just get the important part of a URL, e.g. `http://shax.com/test?uid=129483` → `shax.com/test` */
13
- export declare function formatURL(possible: PossibleURL, base?: PossibleURL): string;
10
+ export declare function getURL(possible: Optional<PossibleURL>, base?: PossibleURL | undefined): URL | undefined;
11
+ /** Convert a possible URL to a URL, or throw `RequiredError` if conversion fails. */
12
+ export declare function requireURL(possible: PossibleURL, base?: PossibleURL, caller?: AnyCaller): URL;
package/util/url.js CHANGED
@@ -1,4 +1,3 @@
1
- import { AssertionError } from "../error/AssertionError.js";
2
1
  import { RequiredError } from "../error/RequiredError.js";
3
2
  import { notOptional } from "./optional.js";
4
3
  /** Is an unknown value a URL object? */
@@ -6,12 +5,12 @@ export function isURL(value) {
6
5
  return value instanceof URL;
7
6
  }
8
7
  /** Assert that an unknown value is a URL object. */
9
- export function assertURL(value) {
8
+ export function assertURL(value, caller = assertURL) {
10
9
  if (!isURL(value))
11
- throw new AssertionError("Invalid URL", { received: value, caller: assertURL });
10
+ throw new RequiredError("Invalid URL", { received: value, caller });
12
11
  }
13
12
  /** Convert a possible URL to a URL, or return `undefined` if conversion fails. */
14
- export function getOptionalURL(possible, base = _BASE) {
13
+ export function getURL(possible, base = _BASE) {
15
14
  if (notOptional(possible)) {
16
15
  try {
17
16
  return isURL(possible) ? possible : new URL(possible, base);
@@ -22,18 +21,9 @@ export function getOptionalURL(possible, base = _BASE) {
22
21
  }
23
22
  }
24
23
  const _BASE = typeof document === "object" ? document.baseURI : undefined;
25
- /** Convert a possible URL to a URL, or throw `AssertionError` if conversion fails. */
26
- export function requireURL(possible, base) {
27
- return _url(requireURL, possible, base);
28
- }
29
- function _url(caller, possible, base) {
30
- const url = getOptionalURL(possible, base);
31
- if (!url)
32
- throw new RequiredError("Invalid URL", { received: possible, caller: requireURL });
24
+ /** Convert a possible URL to a URL, or throw `RequiredError` if conversion fails. */
25
+ export function requireURL(possible, base, caller = requireURL) {
26
+ const url = getURL(possible, base);
27
+ assertURL(url, caller);
33
28
  return url;
34
29
  }
35
- /** Just get the important part of a URL, e.g. `http://shax.com/test?uid=129483` → `shax.com/test` */
36
- export function formatURL(possible, base) {
37
- const { host, pathname } = _url(formatURL, possible, base);
38
- return `${host}${pathname.length > 1 ? pathname : ""}`;
39
- }
@@ -2,7 +2,7 @@ import type { BaseError, BaseErrorOptions } from "../error/BaseError.js";
2
2
  import type { ImmutableArray, PossibleArray } from "./array.js";
3
3
  import type { Constructor } from "./class.js";
4
4
  import type { Data } from "./data.js";
5
- import type { ImmutableDictionary, PossibleDictionary } from "./dictionary.js";
5
+ import type { ImmutableDictionary } from "./dictionary.js";
6
6
  import type { DeepPartial } from "./object.js";
7
7
  /** Object that can validate an unknown value with its `validate()` method. */
8
8
  export interface Validator<T> {
@@ -52,7 +52,7 @@ export declare function validateArray<T>(unsafeArray: PossibleArray<unknown>, va
52
52
  * @throw Feedback if one or more entry values did not validate.
53
53
  * - `feedback.details` will contain an entry for each invalid item (keyed by their count in the input iterable).
54
54
  */
55
- export declare function validateDictionary<T>(unsafeDictionary: PossibleDictionary<unknown>, validator: Validator<T>): ImmutableDictionary<T>;
55
+ export declare function validateDictionary<T>(unsafeDictionary: ImmutableDictionary<unknown>, validator: Validator<T>): ImmutableDictionary<T>;
56
56
  /**
57
57
  * Validate a data object with a set of validators.
58
58
  * - Defined props in the object will be validated against the corresponding validator.
@@ -1,8 +0,0 @@
1
- import { BaseError, type BaseErrorOptions } from "./BaseError.js";
2
- /**
3
- * Thrown when a value is we're asserting something to be true, but it isn't.
4
- * - Usually thrown from `assertX()` functions, e.g. `assertString()` and `assertNumber()`
5
- */
6
- export declare class AssertionError extends BaseError {
7
- constructor(message?: string, options?: BaseErrorOptions);
8
- }
@@ -1,12 +0,0 @@
1
- import { BaseError } from "./BaseError.js";
2
- /**
3
- * Thrown when a value is we're asserting something to be true, but it isn't.
4
- * - Usually thrown from `assertX()` functions, e.g. `assertString()` and `assertNumber()`
5
- */
6
- export class AssertionError extends BaseError {
7
- constructor(message, options) {
8
- super(message, { caller: AssertionError, ...options });
9
- }
10
- }
11
- AssertionError.prototype.name = "AssertionError";
12
- AssertionError.prototype.message = "Assertion failed";