@rogolev/value 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +14 -0
- package/README.md +19 -1
- package/docs/classes/Value/constructor.md +48 -0
- package/docs/classes/Value/get.md +51 -0
- package/docs/classes/Value/getType.md +71 -0
- package/docs/classes/Value/isArray.md +67 -0
- package/docs/classes/Value/isAssoc.md +68 -0
- package/docs/classes/Value/isBigInt.md +52 -0
- package/docs/classes/Value/isBool.md +60 -0
- package/docs/classes/Value/isBoolean.md +60 -0
- package/docs/classes/Value/isClass.md +55 -0
- package/docs/classes/Value/isEmpty.md +84 -0
- package/docs/classes/Value/isFloat.md +52 -0
- package/docs/classes/Value/isFunction.md +60 -0
- package/docs/classes/Value/isInfinity.md +60 -0
- package/docs/classes/Value/isInt.md +52 -0
- package/docs/classes/Value/isInteger.md +52 -0
- package/docs/classes/Value/isList.md +59 -0
- package/docs/classes/Value/isNaN.md +79 -0
- package/docs/classes/Value/isNull.md +59 -0
- package/docs/classes/Value/isNumber.md +80 -0
- package/docs/classes/Value/isNumeric.md +79 -0
- package/docs/classes/Value/isObject.md +68 -0
- package/docs/classes/Value/isScalar.md +72 -0
- package/docs/classes/Value/isString.md +67 -0
- package/docs/classes/Value/isSymbol.md +75 -0
- package/docs/classes/Value/isUndefined.md +67 -0
- package/docs/classes/Value/print.md +164 -0
- package/docs/classes/Value/printType.md +158 -0
- package/docs/classes/Value/setType.md +79 -0
- package/docs/classes/Value/toArray.md +85 -0
- package/docs/classes/Value/toAssoc.md +85 -0
- package/docs/classes/Value/toBool.md +71 -0
- package/docs/classes/Value/toBoolean.md +71 -0
- package/docs/classes/Value/toFloat.md +72 -0
- package/docs/classes/Value/toInt.md +72 -0
- package/docs/classes/Value/toInteger.md +72 -0
- package/docs/classes/Value/toList.md +77 -0
- package/docs/classes/Value/toObject.md +78 -0
- package/docs/classes/Value/toPrint.md +115 -0
- package/docs/classes/Value/toPrintType.md +110 -0
- package/docs/classes/Value/toString.md +134 -0
- package/docs/classes/Value.md +113 -0
- package/docs/classes.md +2 -0
- package/docs/constants.md +47 -0
- package/docs/helpers/value.md +95 -0
- package/docs/helpers.md +2 -0
- package/index.mjs +3 -0
- package/package.json +2 -2
- package/src/classes/Convert.mjs +818 -819
- package/src/classes/Type.mjs +1284 -1285
- package/src/classes/Value.mjs +2846 -0
- package/src/constants.mjs +14 -0
- package/src/helpers/array.mjs +107 -107
- package/src/helpers/empty.mjs +70 -70
- package/src/helpers/gettype.mjs +149 -133
- package/src/helpers/is_array.mjs +128 -128
- package/src/helpers/is_assoc.mjs +51 -51
- package/src/helpers/is_bigint.mjs +47 -47
- package/src/helpers/is_bool.mjs +43 -43
- package/src/helpers/is_boolean.mjs +43 -43
- package/src/helpers/is_class.mjs +87 -87
- package/src/helpers/is_float.mjs +67 -67
- package/src/helpers/is_function.mjs +74 -74
- package/src/helpers/is_infinity.mjs +52 -52
- package/src/helpers/is_int.mjs +57 -57
- package/src/helpers/is_integer.mjs +74 -74
- package/src/helpers/is_list.mjs +43 -43
- package/src/helpers/is_nan.mjs +51 -51
- package/src/helpers/is_null.mjs +37 -37
- package/src/helpers/is_number.mjs +49 -49
- package/src/helpers/is_numeric.mjs +64 -64
- package/src/helpers/is_object.mjs +72 -72
- package/src/helpers/is_scalar.mjs +45 -45
- package/src/helpers/is_string.mjs +46 -46
- package/src/helpers/is_symbol.mjs +46 -46
- package/src/helpers/is_undefined.mjs +44 -44
- package/src/helpers/print.mjs +245 -245
- package/src/helpers/print_type.mjs +261 -261
- package/src/helpers/settype.mjs +101 -101
- package/src/helpers/to_array.mjs +118 -118
- package/src/helpers/to_assoc.mjs +98 -98
- package/src/helpers/to_bool.mjs +68 -68
- package/src/helpers/to_boolean.mjs +64 -64
- package/src/helpers/to_float.mjs +72 -72
- package/src/helpers/to_int.mjs +93 -93
- package/src/helpers/to_integer.mjs +81 -81
- package/src/helpers/to_list.mjs +56 -56
- package/src/helpers/to_object.mjs +94 -94
- package/src/helpers/to_string.mjs +157 -157
- package/src/helpers/value.mjs +92 -0
- package/tests/classes/Convert.test.mjs +398 -399
- package/tests/classes/Type.test.mjs +1262 -1263
- package/tests/classes/Value.test.mjs +423 -0
- package/tests/constants.test.mjs +75 -0
- package/tests/helpers/array.test.mjs +58 -58
- package/tests/helpers/empty.test.mjs +22 -22
- package/tests/helpers/gettype.test.mjs +74 -74
- package/tests/helpers/is_array.test.mjs +404 -404
- package/tests/helpers/is_assoc.test.mjs +42 -42
- package/tests/helpers/is_bigint.test.mjs +51 -51
- package/tests/helpers/is_bool.test.mjs +43 -43
- package/tests/helpers/is_boolean.test.mjs +43 -43
- package/tests/helpers/is_class.test.mjs +84 -84
- package/tests/helpers/is_float.test.mjs +87 -87
- package/tests/helpers/is_function.test.mjs +83 -83
- package/tests/helpers/is_infinity.test.mjs +46 -46
- package/tests/helpers/is_int.test.mjs +45 -45
- package/tests/helpers/is_integer.test.mjs +64 -64
- package/tests/helpers/is_list.test.mjs +42 -42
- package/tests/helpers/is_nan.test.mjs +43 -43
- package/tests/helpers/is_null.test.mjs +17 -17
- package/tests/helpers/is_number.test.mjs +25 -25
- package/tests/helpers/is_numeric.test.mjs +30 -30
- package/tests/helpers/is_object.test.mjs +52 -52
- package/tests/helpers/is_scalar.test.mjs +21 -21
- package/tests/helpers/is_string.test.mjs +20 -20
- package/tests/helpers/is_symbol.test.mjs +20 -20
- package/tests/helpers/is_undefined.test.mjs +18 -18
- package/tests/helpers/print.test.mjs +62 -62
- package/tests/helpers/print_type.test.mjs +62 -62
- package/tests/helpers/settype.test.mjs +34 -34
- package/tests/helpers/to_array.test.mjs +38 -38
- package/tests/helpers/to_assoc.test.mjs +33 -33
- package/tests/helpers/to_bool.test.mjs +51 -51
- package/tests/helpers/to_boolean.test.mjs +51 -51
- package/tests/helpers/to_float.test.mjs +26 -26
- package/tests/helpers/to_int.test.mjs +48 -48
- package/tests/helpers/to_integer.test.mjs +48 -48
- package/tests/helpers/to_list.test.mjs +32 -32
- package/tests/helpers/to_object.test.mjs +36 -36
- package/tests/helpers/to_string.test.mjs +71 -71
- package/tests/helpers/value.test.mjs +68 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
import { expect, test, describe } from '@jest/globals';
|
2
|
+
import { Value, value } from '../../index.mjs';
|
3
|
+
|
4
|
+
describe('Функция value', () => {
|
5
|
+
test('Должна создавать экземпляр класса Value с числом', () => {
|
6
|
+
const val = 123;
|
7
|
+
const result = value(val);
|
8
|
+
expect(result).toBeInstanceOf(Value);
|
9
|
+
expect(result.get()).toBe(val);
|
10
|
+
expect(result.getType()).toBe('integer');
|
11
|
+
expect(result.isNumber()).toBe(true);
|
12
|
+
});
|
13
|
+
|
14
|
+
test('Должна создавать экземпляр класса Value со строкой', () => {
|
15
|
+
const val = 'example';
|
16
|
+
const result = value(val);
|
17
|
+
expect(result).toBeInstanceOf(Value);
|
18
|
+
expect(result.get()).toBe(val);
|
19
|
+
expect(result.getType()).toBe('string');
|
20
|
+
expect(result.isString()).toBe(true);
|
21
|
+
});
|
22
|
+
|
23
|
+
test('Должна создавать экземпляр класса Value с ассоциативным массивом', () => {
|
24
|
+
const val = { key: 'value' };
|
25
|
+
const result = value(val);
|
26
|
+
expect(result).toBeInstanceOf(Value);
|
27
|
+
expect(result.get()).toEqual(val);
|
28
|
+
expect(result.getType()).toBe('array');
|
29
|
+
expect(result.isAssoc()).toBe(true);
|
30
|
+
});
|
31
|
+
|
32
|
+
test('Должна создавать экземпляр класса Value с массивом', () => {
|
33
|
+
const val = [1, 2, 3];
|
34
|
+
const result = value(val);
|
35
|
+
expect(result).toBeInstanceOf(Value);
|
36
|
+
expect(result.get()).toEqual(val);
|
37
|
+
expect(result.getType()).toBe('array');
|
38
|
+
expect(result.isArray()).toBe(true);
|
39
|
+
});
|
40
|
+
|
41
|
+
test('Должна создавать экземпляр класса Value с булевым значением', () => {
|
42
|
+
const val = true;
|
43
|
+
const result = value(val);
|
44
|
+
expect(result).toBeInstanceOf(Value);
|
45
|
+
expect(result.get()).toBe(val);
|
46
|
+
expect(result.getType()).toBe('boolean');
|
47
|
+
expect(result.isBool()).toBe(true);
|
48
|
+
});
|
49
|
+
|
50
|
+
test('Должна создавать экземпляр класса Value с null', () => {
|
51
|
+
const val = null;
|
52
|
+
const result = value(val);
|
53
|
+
expect(result).toBeInstanceOf(Value);
|
54
|
+
expect(result.get()).toBe(val);
|
55
|
+
expect(result.getType()).toBe('null');
|
56
|
+
expect(result.isNull()).toBe(true);
|
57
|
+
});
|
58
|
+
|
59
|
+
test('Должна создавать экземпляр класса Value с undefined', () => {
|
60
|
+
const val = undefined;
|
61
|
+
const result = value(val);
|
62
|
+
expect(result).toBeInstanceOf(Value);
|
63
|
+
expect(result.get()).toBe(val);
|
64
|
+
expect(result.getType()).toBe('undefined');
|
65
|
+
expect(result.isUndefined()).toBe(true);
|
66
|
+
});
|
67
|
+
});
|
68
|
+
|