tsu 1.1.1 → 1.1.2
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/index.d.ts +3 -3
- package/dist/index.js +5 -5
- package/dist/index.mjs +5 -5
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -13,13 +13,13 @@ declare type Obj<V = unknown> = Record<string | symbol | number, V>;
|
|
|
13
13
|
*/
|
|
14
14
|
declare function drop<T>(n: number, array: readonly T[]): T[];
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Splits an array into groups of size s.
|
|
17
17
|
*
|
|
18
|
-
* @param
|
|
18
|
+
* @param s - The size of each group.
|
|
19
19
|
* @param array - The array.
|
|
20
20
|
* @returns The array split into groups.
|
|
21
21
|
*/
|
|
22
|
-
declare function groupsOf<T>(
|
|
22
|
+
declare function groupsOf<T>(s: number, array: readonly T[]): T[][];
|
|
23
23
|
/**
|
|
24
24
|
* Returns the first item of an array.
|
|
25
25
|
*
|
package/dist/index.js
CHANGED
|
@@ -77,16 +77,16 @@ function drop(n, array) {
|
|
|
77
77
|
}
|
|
78
78
|
return array.slice(n);
|
|
79
79
|
}
|
|
80
|
-
function groupsOf(
|
|
81
|
-
if (
|
|
80
|
+
function groupsOf(s, array) {
|
|
81
|
+
if (s <= 0) {
|
|
82
82
|
throw new Error("[tsu] Invalid group size");
|
|
83
83
|
}
|
|
84
|
-
if (
|
|
84
|
+
if (s >= array.length) {
|
|
85
85
|
return [[...array]];
|
|
86
86
|
}
|
|
87
87
|
const groupedArray = [];
|
|
88
|
-
for (let i = 0; i < array.length; i +=
|
|
89
|
-
groupedArray.push(array.slice(i, i +
|
|
88
|
+
for (let i = 0; i < array.length; i += s) {
|
|
89
|
+
groupedArray.push(array.slice(i, i + s));
|
|
90
90
|
}
|
|
91
91
|
return groupedArray;
|
|
92
92
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -5,16 +5,16 @@ function drop(n, array) {
|
|
|
5
5
|
}
|
|
6
6
|
return array.slice(n);
|
|
7
7
|
}
|
|
8
|
-
function groupsOf(
|
|
9
|
-
if (
|
|
8
|
+
function groupsOf(s, array) {
|
|
9
|
+
if (s <= 0) {
|
|
10
10
|
throw new Error("[tsu] Invalid group size");
|
|
11
11
|
}
|
|
12
|
-
if (
|
|
12
|
+
if (s >= array.length) {
|
|
13
13
|
return [[...array]];
|
|
14
14
|
}
|
|
15
15
|
const groupedArray = [];
|
|
16
|
-
for (let i = 0; i < array.length; i +=
|
|
17
|
-
groupedArray.push(array.slice(i, i +
|
|
16
|
+
for (let i = 0; i < array.length; i += s) {
|
|
17
|
+
groupedArray.push(array.slice(i, i + s));
|
|
18
18
|
}
|
|
19
19
|
return groupedArray;
|
|
20
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsu",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "A collection of TypeScript utilities.",
|
|
5
5
|
"author": "eb3n",
|
|
6
6
|
"repository": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"ts-jest": "^27.1.3",
|
|
42
42
|
"tsup": "^5.12.0",
|
|
43
43
|
"typescript": "^4.6.2",
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
}
|
|
44
|
+
"vuepress": "^2.0.0-beta.41"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {}
|
|
47
47
|
}
|