dce-reactkit 3.2.8 → 3.2.9
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/cjs/index.js +50 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/helpers/compareArraysByProp.d.ts +12 -0
- package/dist/cjs/types/helpers/extractProp.d.ts +12 -0
- package/dist/cjs/types/index.d.ts +3 -1
- package/dist/esm/index.js +49 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/helpers/compareArraysByProp.d.ts +12 -0
- package/dist/esm/types/helpers/extractProp.d.ts +12 -0
- package/dist/esm/types/index.d.ts +3 -1
- package/dist/index.d.ts +25 -1
- package/package.json +1 -1
- package/src/helpers/compareArraysByProp.ts +37 -0
- package/src/helpers/extractProp.ts +17 -0
- package/src/index.ts +4 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare two arrays of objects by only comparing the values in a specific
|
|
3
|
+
* property (e.g. compare user arrays by comparing their user.id values)
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
* @param a the first array
|
|
6
|
+
* @param b the second array
|
|
7
|
+
* @param prop the property to compare with
|
|
8
|
+
* @returns true if the arrays contain the same objects as determined by
|
|
9
|
+
* the values associated with each object's prop
|
|
10
|
+
*/
|
|
11
|
+
declare const compareArraysByProp: (a: any[], b: any[], prop: string) => boolean;
|
|
12
|
+
export default compareArraysByProp;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* For every element in an array, extract the value of a prop
|
|
3
|
+
* (e.g. for all user objects, extract their ages and put that into a new
|
|
4
|
+
* ages array)
|
|
5
|
+
* @author Gabe Abrams
|
|
6
|
+
* @param arr the array of objects to operate on
|
|
7
|
+
* @param prop the property to extract from each object
|
|
8
|
+
* @returns new array containing the corresponding values, in order, of each
|
|
9
|
+
* object in the original array
|
|
10
|
+
*/
|
|
11
|
+
declare const extractProp: (arr: any[], prop: string) => any[];
|
|
12
|
+
export default extractProp;
|
|
@@ -51,6 +51,8 @@ import getMonthName from './helpers/getMonthName';
|
|
|
51
51
|
import genCSV from './helpers/genCSV';
|
|
52
52
|
import canReviewLogs from './helpers/canReviewLogs';
|
|
53
53
|
import isMobileOrTablet from './helpers/isMobileOrTablet';
|
|
54
|
+
import extractProp from './helpers/extractProp';
|
|
55
|
+
import compareArraysByProp from './helpers/compareArraysByProp';
|
|
54
56
|
import ModalButtonType from './types/ModalButtonType';
|
|
55
57
|
import ModalSize from './types/ModalSize';
|
|
56
58
|
import ModalType from './types/ModalType';
|
|
@@ -66,4 +68,4 @@ import LogBuiltInMetadata from './types/LogBuiltInMetadata';
|
|
|
66
68
|
import LogMetadataType from './types/LogMetadataType';
|
|
67
69
|
import IntelliTableColumn from './types/IntelliTableColumn';
|
|
68
70
|
import PickableItem from './components/ItemPicker/types/PickableItem';
|
|
69
|
-
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, ParamType, };
|
|
71
|
+
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, ParamType, };
|
package/dist/esm/index.js
CHANGED
|
@@ -5525,6 +5525,54 @@ const canReviewLogs = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
5525
5525
|
return canReview;
|
|
5526
5526
|
});
|
|
5527
5527
|
|
|
5528
|
+
/**
|
|
5529
|
+
* For every element in an array, extract the value of a prop
|
|
5530
|
+
* (e.g. for all user objects, extract their ages and put that into a new
|
|
5531
|
+
* ages array)
|
|
5532
|
+
* @author Gabe Abrams
|
|
5533
|
+
* @param arr the array of objects to operate on
|
|
5534
|
+
* @param prop the property to extract from each object
|
|
5535
|
+
* @returns new array containing the corresponding values, in order, of each
|
|
5536
|
+
* object in the original array
|
|
5537
|
+
*/
|
|
5538
|
+
const extractProp = (arr, prop) => {
|
|
5539
|
+
return arr.map((item) => {
|
|
5540
|
+
return item[prop];
|
|
5541
|
+
});
|
|
5542
|
+
};
|
|
5543
|
+
|
|
5544
|
+
// Import shared helpers
|
|
5545
|
+
/**
|
|
5546
|
+
* Compare two arrays of objects by only comparing the values in a specific
|
|
5547
|
+
* property (e.g. compare user arrays by comparing their user.id values)
|
|
5548
|
+
* @author Gabe Abrams
|
|
5549
|
+
* @param a the first array
|
|
5550
|
+
* @param b the second array
|
|
5551
|
+
* @param prop the property to compare with
|
|
5552
|
+
* @returns true if the arrays contain the same objects as determined by
|
|
5553
|
+
* the values associated with each object's prop
|
|
5554
|
+
*/
|
|
5555
|
+
const compareArraysByProp = (a, b, prop) => {
|
|
5556
|
+
// Extract values for comparison
|
|
5557
|
+
const aVals = new Set(extractProp(a, prop));
|
|
5558
|
+
const bVals = new Set(extractProp(b, prop));
|
|
5559
|
+
// Compare sizes first
|
|
5560
|
+
if (aVals.size !== bVals.size) {
|
|
5561
|
+
return false;
|
|
5562
|
+
}
|
|
5563
|
+
// Same number of items. Make sure every object in aVals appears in bVals
|
|
5564
|
+
// (if so, they should be equivalent since the sizes are the same)
|
|
5565
|
+
// > Create map of items in bVals
|
|
5566
|
+
const inBVals = {}; // item => true if in bVals
|
|
5567
|
+
Array.from(bVals.values()).forEach((item) => {
|
|
5568
|
+
inBVals[item] = true;
|
|
5569
|
+
});
|
|
5570
|
+
// > Loop through aVals and make sure every item is in bVals
|
|
5571
|
+
return Array.from(aVals.values()).every((item) => {
|
|
5572
|
+
return inBVals[item];
|
|
5573
|
+
});
|
|
5574
|
+
};
|
|
5575
|
+
|
|
5528
5576
|
/**
|
|
5529
5577
|
* Days of the week
|
|
5530
5578
|
* @author Gabe Abrams
|
|
@@ -5541,5 +5589,5 @@ var DayOfWeek;
|
|
|
5541
5589
|
})(DayOfWeek || (DayOfWeek = {}));
|
|
5542
5590
|
var DayOfWeek$1 = DayOfWeek;
|
|
5543
5591
|
|
|
5544
|
-
export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek$1 as DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, Variant$1 as Variant, abbreviate, alert$1 as alert, avg, canReviewLogs, ceilToNumDecimals, confirm, floorToNumDecimals, forceNumIntoBounds, genCSV, genRouteHandler, getHumanReadableDate, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
|
|
5592
|
+
export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek$1 as DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, Variant$1 as Variant, abbreviate, alert$1 as alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genRouteHandler, getHumanReadableDate, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
|
|
5545
5593
|
//# sourceMappingURL=index.js.map
|