@rogolev/value 0.0.2 → 0.0.3
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/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,47 @@
|
|
|
1
|
+
[Главная](../README.md) / Константы
|
|
2
|
+
|
|
3
|
+
# Константы
|
|
4
|
+
|
|
5
|
+
Этот файл содержит константы, используемые для определения типов данных в библиотеке.
|
|
6
|
+
|
|
7
|
+
## Сигнатура
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
export const TYPE_NULL: string;
|
|
11
|
+
export const TYPE_NAN: string;
|
|
12
|
+
export const TYPE_UNDEFINED: string;
|
|
13
|
+
export const TYPE_INFINITY: string;
|
|
14
|
+
export const TYPE_BOOLEAN: string;
|
|
15
|
+
export const TYPE_INTEGER: string;
|
|
16
|
+
export const TYPE_BIGINT: string;
|
|
17
|
+
export const TYPE_FLOAT: string;
|
|
18
|
+
export const TYPE_STRING: string;
|
|
19
|
+
export const TYPE_SYMBOL: string;
|
|
20
|
+
export const TYPE_CLASS: string;
|
|
21
|
+
export const TYPE_FUNCTION: string;
|
|
22
|
+
export const TYPE_ARRAY: string;
|
|
23
|
+
export const TYPE_OBJECT: string;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Описание
|
|
27
|
+
|
|
28
|
+
Константы используются для определения типов данных в библиотеке. Они представляют собой строки,
|
|
29
|
+
которые описывают различные типы данных.
|
|
30
|
+
|
|
31
|
+
### Константы
|
|
32
|
+
|
|
33
|
+
- `TYPE_NULL` — Представляет тип `null`.
|
|
34
|
+
- `TYPE_NAN` — Представляет тип `NaN`.
|
|
35
|
+
- `TYPE_UNDEFINED` — Представляет тип `undefined`.
|
|
36
|
+
- `TYPE_INFINITY` — Представляет тип `infinity`.
|
|
37
|
+
- `TYPE_BOOLEAN` — Представляет тип `boolean`.
|
|
38
|
+
- `TYPE_INTEGER` — Представляет тип `integer`.
|
|
39
|
+
- `TYPE_BIGINT` — Представляет тип `bigint`.
|
|
40
|
+
- `TYPE_FLOAT` — Представляет тип `float`.
|
|
41
|
+
- `TYPE_STRING` — Представляет тип `string`.
|
|
42
|
+
- `TYPE_SYMBOL` — Представляет тип `symbol`.
|
|
43
|
+
- `TYPE_CLASS` — Представляет тип `class`.
|
|
44
|
+
- `TYPE_FUNCTION` — Представляет тип `function`.
|
|
45
|
+
- `TYPE_ARRAY` — Представляет тип `array`.
|
|
46
|
+
- `TYPE_OBJECT` — Представляет тип `object`.
|
|
47
|
+
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
[Главная](../../README.md) / [Помощники](../helpers.md) / value
|
|
2
|
+
|
|
3
|
+
[Исходный код](../../src/helpers/value.mjs)
|
|
4
|
+
|
|
5
|
+
# value
|
|
6
|
+
|
|
7
|
+
`value` — Создает новый экземпляр класса `Value` с заданным значением.
|
|
8
|
+
|
|
9
|
+
## Сигнатура функции
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
value(val: any): Value;
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Описание
|
|
16
|
+
|
|
17
|
+
Функция `value` используется для создания нового экземпляра класса `Value` с переданным значением.
|
|
18
|
+
Это позволяет легко обернуть значение в экземпляр класса `Value` и использовать методы класса для
|
|
19
|
+
работы с этим значением.
|
|
20
|
+
|
|
21
|
+
## Параметры
|
|
22
|
+
|
|
23
|
+
- `val` (any): Значение, которое необходимо обернуть в экземпляр класса `Value`.
|
|
24
|
+
|
|
25
|
+
## Возвращаемое значение
|
|
26
|
+
|
|
27
|
+
Возвращает новый экземпляр класса `Value` с переданным значением.
|
|
28
|
+
|
|
29
|
+
## Примеры использования
|
|
30
|
+
|
|
31
|
+
1. Создание экземпляра класса `Value` с числом:
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
const valueInstance = value(123);
|
|
35
|
+
console.log(valueInstance.get()); // 123
|
|
36
|
+
console.log(valueInstance.getType()); // 'integer'
|
|
37
|
+
console.log(valueInstance.isNumber()); // true
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
2. Создание экземпляра класса `Value` со строкой:
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
const valueInstance = value('example');
|
|
44
|
+
console.log(valueInstance.get()); // 'example'
|
|
45
|
+
console.log(valueInstance.getType()); // 'string'
|
|
46
|
+
console.log(valueInstance.isString()); // true
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
3. Создание экземпляра класса `Value` с объектом:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
const obj = { key: 'value' };
|
|
53
|
+
const valueInstance = value(obj);
|
|
54
|
+
console.log(valueInstance.get()); // { key: 'value' }
|
|
55
|
+
console.log(valueInstance.getType()); // 'object'
|
|
56
|
+
console.log(valueInstance.isObject()); // true
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
4. Создание экземпляра класса `Value` с массивом:
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
const arr = [1, 2, 3];
|
|
63
|
+
const valueInstance = value(arr);
|
|
64
|
+
console.log(valueInstance.get()); // [1, 2, 3]
|
|
65
|
+
console.log(valueInstance.getType()); // 'array'
|
|
66
|
+
console.log(valueInstance.isArray()); // true
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
5. Создание экземпляра класса `Value` с булевым значением:
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
const valueInstance = value(true);
|
|
73
|
+
console.log(valueInstance.get()); // true
|
|
74
|
+
console.log(valueInstance.getType()); // 'boolean'
|
|
75
|
+
console.log(valueInstance.isBool()); // true
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
6. Создание экземпляра класса `Value` с null:
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
const valueInstance = value(null);
|
|
82
|
+
console.log(valueInstance.get()); // null
|
|
83
|
+
console.log(valueInstance.getType()); // 'null'
|
|
84
|
+
console.log(valueInstance.isNull()); // true
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
7. Создание экземпляра класса `Value` с undefined:
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
const valueInstance = value(undefined);
|
|
91
|
+
console.log(valueInstance.get()); // undefined
|
|
92
|
+
console.log(valueInstance.getType()); // 'undefined'
|
|
93
|
+
console.log(valueInstance.isUndefined()); // true
|
|
94
|
+
```
|
|
95
|
+
|
package/docs/helpers.md
CHANGED
|
@@ -49,3 +49,5 @@
|
|
|
49
49
|
- [to_list](./helpers/to_list.md) — Преобразует значение в список.
|
|
50
50
|
- [to_object](./helpers/to_object.md) — Преобразует значение в объект.
|
|
51
51
|
- [to_string](./helpers/to_string.md) — Преобразует значение в строку.
|
|
52
|
+
- [value](./helpers/value.md) — Создает новый экземпляр класса `Value` с заданным значением.
|
|
53
|
+
|
package/index.mjs
CHANGED
|
@@ -35,6 +35,9 @@ export { default as empty } from './src/helpers/empty.mjs';
|
|
|
35
35
|
export { default as settype } from './src/helpers/settype.mjs';
|
|
36
36
|
export { default as print } from './src/helpers/print.mjs';
|
|
37
37
|
export { default as print_type } from './src/helpers/print_type.mjs';
|
|
38
|
+
export { default as value } from './src/helpers/value.mjs';
|
|
38
39
|
export { default as Type } from './src/classes/Type.mjs';
|
|
39
40
|
export { default as Convert } from './src/classes/Convert.mjs';
|
|
41
|
+
export { default as Value } from './src/classes/Value.mjs';
|
|
42
|
+
export * from './src/constants.mjs';
|
|
40
43
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rogolev/value",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Библиотека, переосмысливающая типы данных и работу с ними.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"eslint": "^9.18.0",
|
|
36
36
|
"eslint-config-prettier": "^9.1.0",
|
|
37
37
|
"eslint-plugin-prettier": "^5.2.1",
|
|
38
|
+
"globals": "^15.14.0",
|
|
38
39
|
"jest": "^29.7.0",
|
|
39
40
|
"jest-environment-jsdom": "^29.7.0",
|
|
40
41
|
"prettier": "3.4.2"
|
|
@@ -45,4 +46,3 @@
|
|
|
45
46
|
"test": "jest"
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
|