@oscarpalmer/jhunal 0.13.0 → 0.15.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.
@@ -9,14 +9,24 @@ export declare class Schematic<Model> {
9
9
  constructor(properties: ValidatedProperty[]);
10
10
  /**
11
11
  * Does the value match the schema?
12
+ * @param value - Value to validate
13
+ * @returns `true` if the value matches the schema, otherwise `false`
12
14
  */
13
15
  is(value: unknown): value is Model;
14
16
  }
15
17
  /**
16
18
  * Create a schematic from a schema
19
+ * @template Model - Schema type
20
+ * @param schema - Schema to create the schematic from
21
+ * @throws Throws {@link SchematicError} if the schema can not be converted into a schematic
22
+ * @returns A schematic for the given schema
17
23
  */
18
24
  export declare function schematic<Model extends Schema>(schema: Model): Schematic<Infer<Model>>;
19
25
  /**
20
26
  * Create a schematic from a typed schema
27
+ * @template Model - Existing type
28
+ * @param schema - Typed schema to create the schematic from
29
+ * @throws Throws {@link SchematicError} if the schema can not be converted into a schematic
30
+ * @returns A schematic for the given typed schema
21
31
  */
22
32
  export declare function schematic<Model extends PlainObject>(schema: TypedSchema<Model>): Schematic<Model>;
@@ -1,3 +1,3 @@
1
1
  import type { PlainObject } from '@oscarpalmer/atoms/models';
2
2
  import { type ValidatedProperty } from '../models';
3
- export declare function getProperties(original: PlainObject, prefix?: string, fromTypes?: boolean): ValidatedProperty[];
3
+ export declare function getProperties(original: PlainObject, prefix?: string, fromType?: boolean): ValidatedProperty[];
@@ -1,12 +0,0 @@
1
- function compact(array, strict) {
2
- if (!Array.isArray(array)) return [];
3
- if (strict === true) return array.filter(Boolean);
4
- const { length } = array;
5
- const compacted = [];
6
- for (let index = 0; index < length; index += 1) {
7
- const item = array[index];
8
- if (item != null) compacted.push(item);
9
- }
10
- return compacted;
11
- }
12
- export { compact };
@@ -1,24 +0,0 @@
1
- import { compact } from "./array/compact.js";
2
- /**
3
- * Get the string value from any value
4
- * @param value Original value
5
- * @returns String representation of the value
6
- */
7
- function getString(value) {
8
- if (typeof value === "string") return value;
9
- if (value == null) return "";
10
- if (typeof value === "function") return getString(value());
11
- if (typeof value !== "object") return String(value);
12
- const asString = String(value.valueOf?.() ?? value);
13
- return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
14
- }
15
- /**
16
- * Join an array of values into a string
17
- * @param value Array of values
18
- * @param delimiter Delimiter to use between values
19
- * @returns Joined string
20
- */
21
- function join(value, delimiter) {
22
- return compact(value).map(getString).join(typeof delimiter === "string" ? delimiter : "");
23
- }
24
- export { join };