@rogolev/value 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. package/.prettierignore +4 -4
  2. package/CHANGELOG.md +68 -56
  3. package/LICENSE +41 -41
  4. package/README.md +100 -91
  5. package/babel.config.json +20 -20
  6. package/docs/classes/Convert/toArray.md +100 -0
  7. package/docs/classes/Convert/toAssoc.md +90 -0
  8. package/docs/classes/Convert/toBool.md +72 -0
  9. package/docs/classes/Convert/toBoolean.md +72 -0
  10. package/docs/classes/Convert/toFloat.md +69 -0
  11. package/docs/classes/Convert/toInt.md +86 -0
  12. package/docs/classes/Convert/toInteger.md +86 -0
  13. package/docs/classes/Convert/toList.md +73 -0
  14. package/docs/classes/Convert/toObject.md +76 -0
  15. package/docs/classes/Convert/toString.md +125 -0
  16. package/docs/classes/Convert.md +44 -0
  17. package/docs/classes/Type/isArray.md +106 -0
  18. package/docs/classes/Type/isAssoc.md +57 -0
  19. package/docs/classes/Type/isBigInt.md +49 -0
  20. package/docs/classes/Type/isBool.md +51 -0
  21. package/docs/classes/Type/isBoolean.md +51 -0
  22. package/docs/classes/Type/isClass.md +60 -0
  23. package/docs/classes/Type/isEmpty.md +53 -0
  24. package/docs/classes/Type/isFloat.md +77 -0
  25. package/docs/classes/Type/isFunction.md +64 -0
  26. package/docs/classes/Type/isInfinity.md +59 -0
  27. package/docs/classes/Type/isInt.md +77 -0
  28. package/docs/classes/Type/isInteger.md +77 -0
  29. package/docs/classes/Type/isList.md +49 -0
  30. package/docs/classes/Type/isNaN.md +57 -0
  31. package/docs/classes/Type/isNull.md +49 -0
  32. package/docs/classes/Type/isNumber.md +60 -0
  33. package/docs/classes/Type/isNumeric.md +58 -0
  34. package/docs/classes/Type/isObject.md +53 -0
  35. package/docs/classes/Type/isScalar.md +54 -0
  36. package/docs/classes/Type/isString.md +54 -0
  37. package/docs/classes/Type/isSymbol.md +56 -0
  38. package/docs/classes/Type/isUndefined.md +52 -0
  39. package/docs/classes/Type.md +74 -0
  40. package/docs/classes.md +9 -0
  41. package/docs/helpers/array.md +80 -80
  42. package/docs/helpers/empty.md +77 -77
  43. package/docs/helpers/gettype.md +69 -69
  44. package/docs/helpers/is_array.md +105 -105
  45. package/docs/helpers/is_assoc.md +59 -59
  46. package/docs/helpers/is_bigint.md +57 -57
  47. package/docs/helpers/is_bool.md +50 -50
  48. package/docs/helpers/is_boolean.md +50 -50
  49. package/docs/helpers/is_class.md +73 -73
  50. package/docs/helpers/is_float.md +71 -71
  51. package/docs/helpers/is_function.md +62 -62
  52. package/docs/helpers/is_infinity.md +61 -61
  53. package/docs/helpers/is_int.md +81 -81
  54. package/docs/helpers/is_integer.md +82 -82
  55. package/docs/helpers/is_list.md +51 -51
  56. package/docs/helpers/is_nan.md +59 -59
  57. package/docs/helpers/is_null.md +49 -49
  58. package/docs/helpers/is_number.md +67 -67
  59. package/docs/helpers/is_numeric.md +76 -76
  60. package/docs/helpers/is_object.md +69 -69
  61. package/docs/helpers/is_scalar.md +60 -60
  62. package/docs/helpers/is_string.md +58 -58
  63. package/docs/helpers/is_symbol.md +58 -58
  64. package/docs/helpers/is_undefined.md +56 -56
  65. package/docs/helpers/print.md +187 -187
  66. package/docs/helpers/print_type.md +225 -225
  67. package/docs/helpers/settype.md +78 -78
  68. package/docs/helpers/to_array.md +106 -106
  69. package/docs/helpers/to_assoc.md +91 -91
  70. package/docs/helpers/to_bool.md +76 -76
  71. package/docs/helpers/to_boolean.md +77 -77
  72. package/docs/helpers/to_float.md +70 -70
  73. package/docs/helpers/to_int.md +87 -87
  74. package/docs/helpers/to_integer.md +87 -87
  75. package/docs/helpers/to_list.md +47 -47
  76. package/docs/helpers/to_object.md +76 -76
  77. package/docs/helpers/to_string.md +134 -134
  78. package/docs/helpers.md +51 -51
  79. package/docs/types/NaN.md +30 -30
  80. package/docs/types/array.md +252 -252
  81. package/docs/types/bigint.md +34 -34
  82. package/docs/types/boolean.md +47 -47
  83. package/docs/types/class.md +36 -36
  84. package/docs/types/float.md +35 -35
  85. package/docs/types/function.md +121 -121
  86. package/docs/types/infinity.md +32 -32
  87. package/docs/types/integer.md +35 -35
  88. package/docs/types/null.md +23 -23
  89. package/docs/types/object.md +62 -62
  90. package/docs/types/string.md +33 -33
  91. package/docs/types/symbol.md +29 -29
  92. package/docs/types/undefined.md +25 -25
  93. package/docs/types.md +44 -44
  94. package/eslint.config.mjs +1664 -1664
  95. package/index.mjs +40 -37
  96. package/jest.config.mjs +31 -31
  97. package/package.json +48 -47
  98. package/prettier.config.mjs +224 -224
  99. package/src/classes/Convert.mjs +819 -0
  100. package/src/classes/Type.mjs +1285 -0
  101. package/src/helpers/array.mjs +107 -107
  102. package/src/helpers/empty.mjs +70 -70
  103. package/src/helpers/gettype.mjs +133 -133
  104. package/src/helpers/is_array.mjs +128 -128
  105. package/src/helpers/is_assoc.mjs +51 -51
  106. package/src/helpers/is_bigint.mjs +47 -47
  107. package/src/helpers/is_bool.mjs +43 -43
  108. package/src/helpers/is_boolean.mjs +43 -43
  109. package/src/helpers/is_class.mjs +87 -87
  110. package/src/helpers/is_float.mjs +67 -67
  111. package/src/helpers/is_function.mjs +74 -74
  112. package/src/helpers/is_infinity.mjs +52 -52
  113. package/src/helpers/is_int.mjs +57 -57
  114. package/src/helpers/is_integer.mjs +74 -74
  115. package/src/helpers/is_list.mjs +43 -43
  116. package/src/helpers/is_nan.mjs +51 -51
  117. package/src/helpers/is_null.mjs +37 -37
  118. package/src/helpers/is_number.mjs +49 -49
  119. package/src/helpers/is_numeric.mjs +64 -64
  120. package/src/helpers/is_object.mjs +72 -72
  121. package/src/helpers/is_scalar.mjs +45 -45
  122. package/src/helpers/is_string.mjs +46 -46
  123. package/src/helpers/is_symbol.mjs +46 -46
  124. package/src/helpers/is_undefined.mjs +44 -44
  125. package/src/helpers/print.mjs +245 -245
  126. package/src/helpers/print_type.mjs +261 -261
  127. package/src/helpers/settype.mjs +101 -101
  128. package/src/helpers/to_array.mjs +118 -118
  129. package/src/helpers/to_assoc.mjs +98 -98
  130. package/src/helpers/to_bool.mjs +68 -68
  131. package/src/helpers/to_boolean.mjs +64 -64
  132. package/src/helpers/to_float.mjs +72 -72
  133. package/src/helpers/to_int.mjs +93 -93
  134. package/src/helpers/to_integer.mjs +81 -81
  135. package/src/helpers/to_list.mjs +56 -56
  136. package/src/helpers/to_object.mjs +94 -94
  137. package/src/helpers/to_string.mjs +157 -157
  138. package/tests/classes/Convert.test.mjs +399 -0
  139. package/tests/classes/Type.test.mjs +1263 -0
  140. package/tests/helpers/array.test.mjs +58 -58
  141. package/tests/helpers/empty.test.mjs +22 -22
  142. package/tests/helpers/gettype.test.mjs +74 -74
  143. package/tests/helpers/is_array.test.mjs +404 -404
  144. package/tests/helpers/is_assoc.test.mjs +42 -42
  145. package/tests/helpers/is_bigint.test.mjs +51 -51
  146. package/tests/helpers/is_bool.test.mjs +43 -43
  147. package/tests/helpers/is_boolean.test.mjs +43 -43
  148. package/tests/helpers/is_class.test.mjs +84 -84
  149. package/tests/helpers/is_float.test.mjs +87 -87
  150. package/tests/helpers/is_function.test.mjs +83 -83
  151. package/tests/helpers/is_infinity.test.mjs +46 -46
  152. package/tests/helpers/is_int.test.mjs +45 -45
  153. package/tests/helpers/is_integer.test.mjs +64 -64
  154. package/tests/helpers/is_list.test.mjs +42 -42
  155. package/tests/helpers/is_nan.test.mjs +43 -43
  156. package/tests/helpers/is_null.test.mjs +17 -17
  157. package/tests/helpers/is_number.test.mjs +25 -25
  158. package/tests/helpers/is_numeric.test.mjs +30 -30
  159. package/tests/helpers/is_object.test.mjs +52 -52
  160. package/tests/helpers/is_scalar.test.mjs +21 -21
  161. package/tests/helpers/is_string.test.mjs +20 -20
  162. package/tests/helpers/is_symbol.test.mjs +20 -20
  163. package/tests/helpers/is_undefined.test.mjs +18 -18
  164. package/tests/helpers/print.test.mjs +62 -62
  165. package/tests/helpers/print_type.test.mjs +62 -62
  166. package/tests/helpers/settype.test.mjs +34 -34
  167. package/tests/helpers/to_array.test.mjs +38 -38
  168. package/tests/helpers/to_assoc.test.mjs +33 -33
  169. package/tests/helpers/to_bool.test.mjs +51 -51
  170. package/tests/helpers/to_boolean.test.mjs +51 -51
  171. package/tests/helpers/to_float.test.mjs +26 -26
  172. package/tests/helpers/to_int.test.mjs +48 -48
  173. package/tests/helpers/to_integer.test.mjs +48 -48
  174. package/tests/helpers/to_list.test.mjs +32 -32
  175. package/tests/helpers/to_object.test.mjs +36 -36
  176. package/tests/helpers/to_string.test.mjs +71 -71
@@ -1,58 +1,58 @@
1
- import { expect, test, describe } from '@jest/globals';
2
- import { array } from '../../index.mjs';
3
-
4
- describe('Функция array', () => {
5
- test('Должна возвращать массив с единственным элементом, если передан один массив', () => {
6
- const input = [1, 2, 3];
7
- const result = array(input);
8
- expect(result).toEqual([1, 2, 3]);
9
- });
10
-
11
- test('Должна добавлять элементы в массив, если передано несколько значений', () => {
12
- const result = array(1, [2, 3], { a: 10, b: 20 });
13
- expect(result).toEqual([1, [2, 3], { a: 10, b: 20 }]);
14
- });
15
-
16
- test('Должна обрабатывать ассоциативные массивы (объекты с ключами и значениями)', () => {
17
- const assoc = { key1: 'value1', key2: 'value2' };
18
- const result = array(assoc);
19
- expect(result).toEqual(assoc); // Элемент должен быть объектом
20
- expect(Object.getPrototypeOf(result)).toBeNull(); // Прототип должен быть null
21
- });
22
-
23
- test('Должна создавать итератор для ассоциативного массива', () => {
24
- const assoc = { key: 'value', anotherKey: 'anotherValue' };
25
- const result = array(assoc);
26
-
27
- const iteratorOutput = [];
28
- for (const [key, value] of result) {
29
- iteratorOutput.push([key, value]);
30
- }
31
-
32
- expect(iteratorOutput).toEqual([
33
- ['key', 'value'],
34
- ['anotherKey', 'anotherValue'],
35
- ]);
36
- });
37
-
38
- test('Должна возвращать исходный массив, если он передан как единственный аргумент', () => {
39
- const nestedArray = [1, 2, 3];
40
- const result = array(nestedArray);
41
- expect(result).toBe(nestedArray); // Массив должен быть возвращен напрямую
42
- });
43
-
44
- test('Должна работать с примитивными значениями', () => {
45
- const result = array(42, 'test', true, null);
46
- expect(result).toEqual([42, 'test', true, null]);
47
- });
48
-
49
- test('Должна возвращать массив, если передано несколько различных типов', () => {
50
- const result = array(1, 'text', [2, 3], { foo: 'bar' });
51
- expect(result).toEqual([1, 'text', [2, 3], { foo: 'bar' }]);
52
- });
53
-
54
- test('Должна возвращать массив с объектами и ассоциативными массивами', () => {
55
- const result = array({ key1: 'value1' }, [1, 2], { key2: 'value2' });
56
- expect(result).toEqual([{ key1: 'value1' }, [1, 2], { key2: 'value2' }]);
57
- });
58
- });
1
+ import { expect, test, describe } from '@jest/globals';
2
+ import { array } from '../../index.mjs';
3
+
4
+ describe('Функция array', () => {
5
+ test('Должна возвращать массив с единственным элементом, если передан один массив', () => {
6
+ const input = [1, 2, 3];
7
+ const result = array(input);
8
+ expect(result).toEqual([1, 2, 3]);
9
+ });
10
+
11
+ test('Должна добавлять элементы в массив, если передано несколько значений', () => {
12
+ const result = array(1, [2, 3], { a: 10, b: 20 });
13
+ expect(result).toEqual([1, [2, 3], { a: 10, b: 20 }]);
14
+ });
15
+
16
+ test('Должна обрабатывать ассоциативные массивы (объекты с ключами и значениями)', () => {
17
+ const assoc = { key1: 'value1', key2: 'value2' };
18
+ const result = array(assoc);
19
+ expect(result).toEqual(assoc); // Элемент должен быть объектом
20
+ expect(Object.getPrototypeOf(result)).toBeNull(); // Прототип должен быть null
21
+ });
22
+
23
+ test('Должна создавать итератор для ассоциативного массива', () => {
24
+ const assoc = { key: 'value', anotherKey: 'anotherValue' };
25
+ const result = array(assoc);
26
+
27
+ const iteratorOutput = [];
28
+ for (const [key, value] of result) {
29
+ iteratorOutput.push([key, value]);
30
+ }
31
+
32
+ expect(iteratorOutput).toEqual([
33
+ ['key', 'value'],
34
+ ['anotherKey', 'anotherValue'],
35
+ ]);
36
+ });
37
+
38
+ test('Должна возвращать исходный массив, если он передан как единственный аргумент', () => {
39
+ const nestedArray = [1, 2, 3];
40
+ const result = array(nestedArray);
41
+ expect(result).toBe(nestedArray); // Массив должен быть возвращен напрямую
42
+ });
43
+
44
+ test('Должна работать с примитивными значениями', () => {
45
+ const result = array(42, 'test', true, null);
46
+ expect(result).toEqual([42, 'test', true, null]);
47
+ });
48
+
49
+ test('Должна возвращать массив, если передано несколько различных типов', () => {
50
+ const result = array(1, 'text', [2, 3], { foo: 'bar' });
51
+ expect(result).toEqual([1, 'text', [2, 3], { foo: 'bar' }]);
52
+ });
53
+
54
+ test('Должна возвращать массив с объектами и ассоциативными массивами', () => {
55
+ const result = array({ key1: 'value1' }, [1, 2], { key2: 'value2' });
56
+ expect(result).toEqual([{ key1: 'value1' }, [1, 2], { key2: 'value2' }]);
57
+ });
58
+ });
@@ -1,22 +1,22 @@
1
- import { expect, test, describe } from '@jest/globals';
2
- import { empty } from '../../index.mjs';
3
-
4
- describe('Функция empty', () => {
5
- test('Должна возвращать true для пустых значений', () => {
6
- expect(empty(null)).toBe(true);
7
- expect(empty(undefined)).toBe(true);
8
- expect(empty('')).toBe(true);
9
- expect(empty(0)).toBe(true);
10
- expect(empty(false)).toBe(true);
11
- expect(empty([])).toBe(true);
12
- expect(empty({})).toBe(true);
13
- });
14
-
15
- test('Должна возвращать false для непустых значений', () => {
16
- expect(empty('example')).toBe(false);
17
- expect(empty(123)).toBe(false);
18
- expect(empty(true)).toBe(false);
19
- expect(empty([1, 2, 3])).toBe(false);
20
- expect(empty({ key: 'value' })).toBe(false);
21
- });
22
- });
1
+ import { expect, test, describe } from '@jest/globals';
2
+ import { empty } from '../../index.mjs';
3
+
4
+ describe('Функция empty', () => {
5
+ test('Должна возвращать true для пустых значений', () => {
6
+ expect(empty(null)).toBe(true);
7
+ expect(empty(undefined)).toBe(true);
8
+ expect(empty('')).toBe(true);
9
+ expect(empty(0)).toBe(true);
10
+ expect(empty(false)).toBe(true);
11
+ expect(empty([])).toBe(true);
12
+ expect(empty({})).toBe(true);
13
+ });
14
+
15
+ test('Должна возвращать false для непустых значений', () => {
16
+ expect(empty('example')).toBe(false);
17
+ expect(empty(123)).toBe(false);
18
+ expect(empty(true)).toBe(false);
19
+ expect(empty([1, 2, 3])).toBe(false);
20
+ expect(empty({ key: 'value' })).toBe(false);
21
+ });
22
+ });
@@ -1,74 +1,74 @@
1
- import { expect, test } from '@jest/globals';
2
- import { gettype } from '../../index.mjs';
3
-
4
- describe('Функция gettype', () => {
5
- test('должна возвращать "null" для null', () => {
6
- expect(gettype(null)).toBe('null');
7
- });
8
-
9
- test('должна возвращать "NaN" для NaN', () => {
10
- expect(gettype(NaN)).toBe('NaN');
11
- });
12
-
13
- test('должна возвращать "undefined" для undefined', () => {
14
- expect(gettype(undefined)).toBe('undefined');
15
- });
16
-
17
- test('должна возвращать "infinity" для Infinity и -Infinity', () => {
18
- expect(gettype(Infinity)).toBe('infinity');
19
- expect(gettype(-Infinity)).toBe('infinity');
20
- });
21
-
22
- test('должна возвращать "boolean" для логических значений', () => {
23
- expect(gettype(true)).toBe('boolean');
24
- expect(gettype(false)).toBe('boolean');
25
- });
26
-
27
- test('должна возвращать "integer" для целых чисел', () => {
28
- expect(gettype(42)).toBe('integer');
29
- expect(gettype(-42)).toBe('integer');
30
- expect(gettype(0)).toBe('integer');
31
- });
32
-
33
- test('должна возвращать "bigint" для значений типа BigInt', () => {
34
- expect(gettype(BigInt(123456))).toBe('bigint');
35
- expect(gettype(BigInt(-123456))).toBe('bigint');
36
- });
37
-
38
- test('должна возвращать "float" для чисел с плавающей точкой', () => {
39
- expect(gettype(3.14)).toBe('float');
40
- expect(gettype(-0.99)).toBe('float');
41
- });
42
-
43
- test('должна возвращать "string" для строк', () => {
44
- expect(gettype('hello')).toBe('string');
45
- expect(gettype('')).toBe('string');
46
- });
47
-
48
- test('должна возвращать "symbol" для символов', () => {
49
- expect(gettype(Symbol('symbol'))).toBe('symbol');
50
- });
51
-
52
- test('должна возвращать "class" для классов', () => {
53
- class MyClass {}
54
- expect(gettype(MyClass)).toBe('class');
55
- });
56
-
57
- test('должна возвращать "function" для функций', () => {
58
- function func() {}
59
- expect(gettype(func)).toBe('function');
60
- expect(gettype(() => {})).toBe('function');
61
- });
62
-
63
- test('должна возвращать "array" для массивов', () => {
64
- expect(gettype([])).toBe('array');
65
- expect(gettype([1, 2, 3])).toBe('array');
66
- expect(gettype({})).toBe('array');
67
- expect(gettype({ foo: 'bar' })).toBe('array');
68
- });
69
-
70
- test('должна возвращать "object" для объектов', () => {
71
- class MyClass {}
72
- expect(gettype(new MyClass())).toBe('object');
73
- });
74
- });
1
+ import { expect, test } from '@jest/globals';
2
+ import { gettype } from '../../index.mjs';
3
+
4
+ describe('Функция gettype', () => {
5
+ test('должна возвращать "null" для null', () => {
6
+ expect(gettype(null)).toBe('null');
7
+ });
8
+
9
+ test('должна возвращать "NaN" для NaN', () => {
10
+ expect(gettype(NaN)).toBe('NaN');
11
+ });
12
+
13
+ test('должна возвращать "undefined" для undefined', () => {
14
+ expect(gettype(undefined)).toBe('undefined');
15
+ });
16
+
17
+ test('должна возвращать "infinity" для Infinity и -Infinity', () => {
18
+ expect(gettype(Infinity)).toBe('infinity');
19
+ expect(gettype(-Infinity)).toBe('infinity');
20
+ });
21
+
22
+ test('должна возвращать "boolean" для логических значений', () => {
23
+ expect(gettype(true)).toBe('boolean');
24
+ expect(gettype(false)).toBe('boolean');
25
+ });
26
+
27
+ test('должна возвращать "integer" для целых чисел', () => {
28
+ expect(gettype(42)).toBe('integer');
29
+ expect(gettype(-42)).toBe('integer');
30
+ expect(gettype(0)).toBe('integer');
31
+ });
32
+
33
+ test('должна возвращать "bigint" для значений типа BigInt', () => {
34
+ expect(gettype(BigInt(123456))).toBe('bigint');
35
+ expect(gettype(BigInt(-123456))).toBe('bigint');
36
+ });
37
+
38
+ test('должна возвращать "float" для чисел с плавающей точкой', () => {
39
+ expect(gettype(3.14)).toBe('float');
40
+ expect(gettype(-0.99)).toBe('float');
41
+ });
42
+
43
+ test('должна возвращать "string" для строк', () => {
44
+ expect(gettype('hello')).toBe('string');
45
+ expect(gettype('')).toBe('string');
46
+ });
47
+
48
+ test('должна возвращать "symbol" для символов', () => {
49
+ expect(gettype(Symbol('symbol'))).toBe('symbol');
50
+ });
51
+
52
+ test('должна возвращать "class" для классов', () => {
53
+ class MyClass {}
54
+ expect(gettype(MyClass)).toBe('class');
55
+ });
56
+
57
+ test('должна возвращать "function" для функций', () => {
58
+ function func() {}
59
+ expect(gettype(func)).toBe('function');
60
+ expect(gettype(() => {})).toBe('function');
61
+ });
62
+
63
+ test('должна возвращать "array" для массивов', () => {
64
+ expect(gettype([])).toBe('array');
65
+ expect(gettype([1, 2, 3])).toBe('array');
66
+ expect(gettype({})).toBe('array');
67
+ expect(gettype({ foo: 'bar' })).toBe('array');
68
+ });
69
+
70
+ test('должна возвращать "object" для объектов', () => {
71
+ class MyClass {}
72
+ expect(gettype(new MyClass())).toBe('object');
73
+ });
74
+ });