@degenerate/generic 0.0.13 → 0.0.14
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.
|
@@ -4,5 +4,13 @@
|
|
|
4
4
|
* @param incomingArray the incoming array to get a random item from.
|
|
5
5
|
*/
|
|
6
6
|
declare const getRandomItemFromArray: <T>(incomingArray: T[]) => T;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* This ensures that all items in an array are of the same type.
|
|
9
|
+
*
|
|
10
|
+
* @param array the array to check
|
|
11
|
+
* @param type the type to check against
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
declare const checkIfAllItemsInAnArrayAreSameType: (array: unknown[], type: string) => boolean;
|
|
15
|
+
export { getRandomItemFromArray, checkIfAllItemsInAnArrayAreSameType, };
|
|
8
16
|
//# sourceMappingURL=array-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/array/array-helpers.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,QAAA,MAAM,sBAAsB,GAAI,CAAC,iBAAiB,CAAC,EAAE,KAAG,CAGvD,CAAC;AAEF,OAAO,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"array-helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/array/array-helpers.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,QAAA,MAAM,sBAAsB,GAAI,CAAC,iBAAiB,CAAC,EAAE,KAAG,CAGvD,CAAC;AAEF;;;;;;GAMG;AACH,QAAA,MAAM,mCAAmC,UAAW,OAAO,EAAE,QAAQ,MAAM,KAAG,OAE7E,CAAC;AAEF,OAAO,EACH,sBAAsB,EACtB,mCAAmC,GACtC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file contains the helper functions for arrays.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getRandomItemFromArray = void 0;
|
|
4
|
+
exports.checkIfAllItemsInAnArrayAreSameType = exports.getRandomItemFromArray = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* this gets a random item from an array.
|
|
7
7
|
*
|
|
@@ -12,3 +12,14 @@ const getRandomItemFromArray = (incomingArray) => {
|
|
|
12
12
|
return incomingArray[randomIndex];
|
|
13
13
|
};
|
|
14
14
|
exports.getRandomItemFromArray = getRandomItemFromArray;
|
|
15
|
+
/**
|
|
16
|
+
* This ensures that all items in an array are of the same type.
|
|
17
|
+
*
|
|
18
|
+
* @param array the array to check
|
|
19
|
+
* @param type the type to check against
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
const checkIfAllItemsInAnArrayAreSameType = (array, type) => {
|
|
23
|
+
return array.every(item => typeof item === type);
|
|
24
|
+
};
|
|
25
|
+
exports.checkIfAllItemsInAnArrayAreSameType = checkIfAllItemsInAnArrayAreSameType;
|
package/package.json
CHANGED