shelving 1.86.6 → 1.86.7
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/package.json +1 -1
- package/util/data.d.ts +2 -0
- package/util/data.js +6 -0
- package/util/object.d.ts +1 -1
package/package.json
CHANGED
package/util/data.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export type Datas = {
|
|
|
17
17
|
};
|
|
18
18
|
/** Is an unknown value a data object? */
|
|
19
19
|
export declare const isData: <T extends Data>(value: unknown) => value is T;
|
|
20
|
+
/** Assert that an unknown value is a data object. */
|
|
21
|
+
export declare function assertData<T extends Data>(value: T | unknown): asserts value is T;
|
|
20
22
|
/** Is an unknown value the key for an own prop of a data object. */
|
|
21
23
|
export declare const isDataKey: <T extends Data>(obj: T, key: unknown) => key is DataKey<T>;
|
|
22
24
|
/** Get the data of a result (returns data or throws `RequiredError` if value is `null` or `undefined`). */
|
package/util/data.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { AssertionError } from "../error/AssertionError.js";
|
|
1
2
|
import { RequiredError } from "../error/RequiredError.js";
|
|
2
3
|
import { isPlainObject } from "./object.js";
|
|
3
4
|
/** Is an unknown value a data object? */
|
|
4
5
|
export const isData = (value) => isPlainObject(value);
|
|
6
|
+
/** Assert that an unknown value is a data object. */
|
|
7
|
+
export function assertData(value) {
|
|
8
|
+
if (!isPlainObject(value))
|
|
9
|
+
throw new AssertionError("Must be data", value);
|
|
10
|
+
}
|
|
5
11
|
/** Is an unknown value the key for an own prop of a data object. */
|
|
6
12
|
export const isDataKey = (obj, key) => typeof key === "string" && Object.prototype.hasOwnProperty.call(obj, key);
|
|
7
13
|
/** Get the data of a result (returns data or throws `RequiredError` if value is `null` or `undefined`). */
|
package/util/object.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type ObjectValue<T extends ImmutableObject = ImmutableObject> = T[keyof T
|
|
|
16
16
|
/** Is an unknown value an unknown object? */
|
|
17
17
|
export declare const isObject: <T extends ImmutableObject<PropertyKey, unknown>>(value: unknown) => value is T;
|
|
18
18
|
/** Assert that a value is an object */
|
|
19
|
-
export declare function assertObject(value:
|
|
19
|
+
export declare function assertObject<T extends ImmutableObject>(value: T | unknown): asserts value is T;
|
|
20
20
|
/** is an unknown value an unknown plain object? */
|
|
21
21
|
export declare function isPlainObject(value: ImmutableObject | unknown): value is ImmutableObject;
|
|
22
22
|
/** Assert that a value is an object */
|