@gesslar/sassy 0.21.1 → 0.22.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.
package/src/Valid.js DELETED
@@ -1,50 +0,0 @@
1
- import _assert from "node:assert/strict"
2
-
3
- import Sass from "./Sass.js"
4
- import Data from "./Data.js"
5
-
6
- export default class Valid {
7
- /**
8
- * Validates a value against a type
9
- *
10
- * @param {unknown} value - The value to validate
11
- * @param {string} type - The expected type in the form of "object",
12
- * "object[]", "object|object[]"
13
- * @param {object} [options] - Additional options for validation.
14
- */
15
- static validType(value, type, options) {
16
- Valid.assert(
17
- Data.isType(value, type, options),
18
- `Invalid type. Expected ${type}, got ${JSON.stringify(value)}`,
19
- 1,
20
- )
21
- }
22
-
23
- /**
24
- * Asserts a condition
25
- *
26
- * @param {boolean} condition - The condition to assert
27
- * @param {string} message - The message to display if the condition is not
28
- * met
29
- * @param {number} [arg] - The argument to display if the condition is not
30
- * met (optional)
31
- */
32
- static assert(condition, message, arg = null) {
33
- _assert(
34
- Data.isType(condition, "boolean"),
35
- `Condition must be a boolean, got ${condition}`,
36
- )
37
- _assert(
38
- Data.isType(message, "string"),
39
- `Message must be a string, got ${message}`,
40
- )
41
- _assert(
42
- arg !== null || arg !== undefined && typeof arg === "number",
43
- `Arg must be a number, got ${arg}`,
44
- )
45
-
46
- if(!condition)
47
- throw Sass.new(`${message}${arg ? `: ${arg}` : ""}`)
48
- }
49
-
50
- }