@hapl/api-queries 1.0.21 → 1.0.22
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/dist/api-queries.cjs.development.js +86 -3
- package/dist/api-queries.cjs.development.js.map +1 -1
- package/dist/api-queries.cjs.production.min.js +1 -1
- package/dist/api-queries.cjs.production.min.js.map +1 -1
- package/dist/api-queries.esm.js +86 -3
- package/dist/api-queries.esm.js.map +1 -1
- package/dist/utils.d.ts +62 -0
- package/package.json +1 -3
- package/src/clients/v1/api/file/uploadFile.ts +1 -2
- package/src/clients/v1/api/file/uploadFiles.ts +1 -1
- package/src/publisher/api/uploadResume.ts +1 -1
- package/src/search/api/buildings/findBuildingCoordinates.ts +1 -1
- package/src/search/api/buildings/findBuildingOffers.ts +1 -1
- package/src/utils.ts +87 -0
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits an array into smaller arrays of a specified length.
|
|
3
|
+
*
|
|
4
|
+
* This function takes an input array and divides it into multiple smaller arrays,
|
|
5
|
+
* each of a specified length. If the input array cannot be evenly divided,
|
|
6
|
+
* the final sub-array will contain the remaining elements.
|
|
7
|
+
*
|
|
8
|
+
* @template T The type of elements in the array.
|
|
9
|
+
* @param {T[]} arr - The array to be chunked into smaller arrays.
|
|
10
|
+
* @param {number} size - The size of each smaller array. Must be a positive integer.
|
|
11
|
+
* @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.
|
|
12
|
+
* @throws {Error} Throws an error if `size` is not a positive integer.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Splits an array of numbers into sub-arrays of length 2
|
|
16
|
+
* chunk([1, 2, 3, 4, 5], 2);
|
|
17
|
+
* // Returns: [[1, 2], [3, 4], [5]]
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Splits an array of strings into sub-arrays of length 3
|
|
21
|
+
* chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
|
|
22
|
+
* // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
|
|
23
|
+
*/
|
|
24
|
+
export declare function chunk<T>(arr: readonly T[], size: number): T[][];
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a given value is null or undefined.
|
|
27
|
+
*
|
|
28
|
+
* This function tests whether the provided value is either `null` or `undefined`.
|
|
29
|
+
* It returns `true` if the value is `null` or `undefined`, and `false` otherwise.
|
|
30
|
+
*
|
|
31
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.
|
|
32
|
+
*
|
|
33
|
+
* @param {unknown} x - The value to test for null or undefined.
|
|
34
|
+
* @returns {boolean} `true` if the value is null or undefined, `false` otherwise.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const value1 = null;
|
|
38
|
+
* const value2 = undefined;
|
|
39
|
+
* const value3 = 42;
|
|
40
|
+
* const result1 = isNil(value1); // true
|
|
41
|
+
* const result2 = isNil(value2); // true
|
|
42
|
+
* const result3 = isNil(value3); // false
|
|
43
|
+
*/
|
|
44
|
+
export declare function isNil(x: unknown): x is null | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Checks if a given value is string.
|
|
47
|
+
*
|
|
48
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `string`.
|
|
49
|
+
*
|
|
50
|
+
* @param {unknown} value The value to check if it is string.
|
|
51
|
+
* @returns {value is string} Returns `true` if `value` is a string, else `false`.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* const value1 = 'abc';
|
|
55
|
+
* const value2 = 123;
|
|
56
|
+
* const value3 = true;
|
|
57
|
+
*
|
|
58
|
+
* console.log(isString(value1)); // true
|
|
59
|
+
* console.log(isString(value2)); // false
|
|
60
|
+
* console.log(isString(value3)); // false
|
|
61
|
+
*/
|
|
62
|
+
export declare function isString(value: unknown): value is string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hapl/api-queries",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"author": "Homeapp",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/api-queries.esm.js",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@types/lodash": "^4.14.192",
|
|
43
42
|
"@types/qs": "^6.9.7",
|
|
44
43
|
"auto": "11.3.6",
|
|
45
44
|
"husky": "^7.0.1",
|
|
@@ -49,7 +48,6 @@
|
|
|
49
48
|
},
|
|
50
49
|
"dependencies": {
|
|
51
50
|
"axios": "^1.3.5",
|
|
52
|
-
"lodash": "^4.17.21",
|
|
53
51
|
"nanoid": "3.3.6",
|
|
54
52
|
"qs": "^6.11.1"
|
|
55
53
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer, AxiosRequestConfig } from 'axios';
|
|
2
|
-
import isNil from '
|
|
3
|
-
import isString from 'lodash/isString';
|
|
2
|
+
import { isNil, isString } from '../../../../utils';
|
|
4
3
|
import { File } from '../../types';
|
|
5
4
|
import { DEFAULT_BASE_URL } from '../../../constants';
|
|
6
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer } from 'axios';
|
|
2
|
-
import isString from '
|
|
2
|
+
import { isString } from '../../../../utils';
|
|
3
3
|
import { File } from '../../types';
|
|
4
4
|
import { DEFAULT_BASE_URL } from '../../../constants';
|
|
5
5
|
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* Код взят c https://github.com/toss/es-toolkit */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Splits an array into smaller arrays of a specified length.
|
|
5
|
+
*
|
|
6
|
+
* This function takes an input array and divides it into multiple smaller arrays,
|
|
7
|
+
* each of a specified length. If the input array cannot be evenly divided,
|
|
8
|
+
* the final sub-array will contain the remaining elements.
|
|
9
|
+
*
|
|
10
|
+
* @template T The type of elements in the array.
|
|
11
|
+
* @param {T[]} arr - The array to be chunked into smaller arrays.
|
|
12
|
+
* @param {number} size - The size of each smaller array. Must be a positive integer.
|
|
13
|
+
* @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.
|
|
14
|
+
* @throws {Error} Throws an error if `size` is not a positive integer.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Splits an array of numbers into sub-arrays of length 2
|
|
18
|
+
* chunk([1, 2, 3, 4, 5], 2);
|
|
19
|
+
* // Returns: [[1, 2], [3, 4], [5]]
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Splits an array of strings into sub-arrays of length 3
|
|
23
|
+
* chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
|
|
24
|
+
* // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
|
|
25
|
+
*/
|
|
26
|
+
export function chunk<T>(arr: readonly T[], size: number): T[][] {
|
|
27
|
+
if (!Number.isInteger(size) || size <= 0) {
|
|
28
|
+
throw new Error('Size must be an integer greater than zero.');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const chunkLength = Math.ceil(arr.length / size);
|
|
32
|
+
const result: T[][] = Array(chunkLength);
|
|
33
|
+
|
|
34
|
+
for (let index = 0; index < chunkLength; index++) {
|
|
35
|
+
const start = index * size;
|
|
36
|
+
const end = start + size;
|
|
37
|
+
|
|
38
|
+
result[index] = arr.slice(start, end);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Checks if a given value is null or undefined.
|
|
46
|
+
*
|
|
47
|
+
* This function tests whether the provided value is either `null` or `undefined`.
|
|
48
|
+
* It returns `true` if the value is `null` or `undefined`, and `false` otherwise.
|
|
49
|
+
*
|
|
50
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.
|
|
51
|
+
*
|
|
52
|
+
* @param {unknown} x - The value to test for null or undefined.
|
|
53
|
+
* @returns {boolean} `true` if the value is null or undefined, `false` otherwise.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const value1 = null;
|
|
57
|
+
* const value2 = undefined;
|
|
58
|
+
* const value3 = 42;
|
|
59
|
+
* const result1 = isNil(value1); // true
|
|
60
|
+
* const result2 = isNil(value2); // true
|
|
61
|
+
* const result3 = isNil(value3); // false
|
|
62
|
+
*/
|
|
63
|
+
export function isNil(x: unknown): x is null | undefined {
|
|
64
|
+
return x == null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Checks if a given value is string.
|
|
69
|
+
*
|
|
70
|
+
* This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `string`.
|
|
71
|
+
*
|
|
72
|
+
* @param {unknown} value The value to check if it is string.
|
|
73
|
+
* @returns {value is string} Returns `true` if `value` is a string, else `false`.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const value1 = 'abc';
|
|
77
|
+
* const value2 = 123;
|
|
78
|
+
* const value3 = true;
|
|
79
|
+
*
|
|
80
|
+
* console.log(isString(value1)); // true
|
|
81
|
+
* console.log(isString(value2)); // false
|
|
82
|
+
* console.log(isString(value3)); // false
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
export function isString(value: unknown): value is string {
|
|
86
|
+
return typeof value === 'string';
|
|
87
|
+
}
|