@gesslar/toolkit 0.1.4 → 0.1.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gesslar/toolkit",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Get in, bitches, we're going toolkitting.",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/src/lib/Data.js CHANGED
@@ -273,9 +273,9 @@ export default class Data {
273
273
  * @returns {Promise<object>} The mapped object
274
274
  */
275
275
  static async mapObject(original, transformer, mutate = false) {
276
- Valid.validType(original, "object", {allowEmpty: true})
277
- Valid.validType(transformer, "function")
278
- Valid.validType(mutate, "boolean")
276
+ Valid.type(original, "object", {allowEmpty: true})
277
+ Valid.type(transformer, "function")
278
+ Valid.type(mutate, "boolean")
279
279
 
280
280
  const result = mutate ? original : {}
281
281
 
package/src/lib/Valid.js CHANGED
@@ -5,14 +5,13 @@ import Data from "./Data.js"
5
5
 
6
6
  export default class Valid {
7
7
  /**
8
- * Validates a value against a type
8
+ * Validates a value against a type. Uses Data.isType.
9
9
  *
10
10
  * @param {unknown} value - The value to validate
11
- * @param {string} type - The expected type in the form of "object",
12
- * "object[]", "object|object[]"
11
+ * @param {string} type - The expected type in the form of "object", "object[]", "object|object[]"
13
12
  * @param {object} [options] - Additional options for validation.
14
13
  */
15
- static validType(value, type, options) {
14
+ static type(value, type, options) {
16
15
  Valid.assert(
17
16
  Data.isType(value, type, options),
18
17
  `Invalid type. Expected ${type}, got ${JSON.stringify(value)}`,
@@ -3,8 +3,8 @@
3
3
 
4
4
  export default class Valid {
5
5
  /** Validate a value against a type specification */
6
- static validType(value: unknown, type: string, options?: { allowEmpty?: boolean }): void
6
+ static type(value: unknown, type: string, options?: { allowEmpty?: boolean }): void
7
7
 
8
8
  /** Assert a condition */
9
9
  static assert(condition: boolean, message: string, arg?: number | null): void
10
- }
10
+ }