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/index.d.ts
CHANGED
|
@@ -1025,6 +1025,30 @@ declare const canReviewLogs: () => Promise<boolean>;
|
|
|
1025
1025
|
*/
|
|
1026
1026
|
declare const isMobileOrTablet: () => boolean;
|
|
1027
1027
|
|
|
1028
|
+
/**
|
|
1029
|
+
* For every element in an array, extract the value of a prop
|
|
1030
|
+
* (e.g. for all user objects, extract their ages and put that into a new
|
|
1031
|
+
* ages array)
|
|
1032
|
+
* @author Gabe Abrams
|
|
1033
|
+
* @param arr the array of objects to operate on
|
|
1034
|
+
* @param prop the property to extract from each object
|
|
1035
|
+
* @returns new array containing the corresponding values, in order, of each
|
|
1036
|
+
* object in the original array
|
|
1037
|
+
*/
|
|
1038
|
+
declare const extractProp: (arr: any[], prop: string) => any[];
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* Compare two arrays of objects by only comparing the values in a specific
|
|
1042
|
+
* property (e.g. compare user arrays by comparing their user.id values)
|
|
1043
|
+
* @author Gabe Abrams
|
|
1044
|
+
* @param a the first array
|
|
1045
|
+
* @param b the second array
|
|
1046
|
+
* @param prop the property to compare with
|
|
1047
|
+
* @returns true if the arrays contain the same objects as determined by
|
|
1048
|
+
* the values associated with each object's prop
|
|
1049
|
+
*/
|
|
1050
|
+
declare const compareArraysByProp: (a: any[], b: any[], prop: string) => boolean;
|
|
1051
|
+
|
|
1028
1052
|
/**
|
|
1029
1053
|
* List of error codes built into the react kit
|
|
1030
1054
|
* @author Gabe Abrams
|
|
@@ -1073,4 +1097,4 @@ declare const LogBuiltInMetadata: {
|
|
|
1073
1097
|
};
|
|
1074
1098
|
};
|
|
1075
1099
|
|
|
1076
|
-
export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, 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 };
|
|
1100
|
+
export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, 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 };
|
package/package.json
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Import shared helpers
|
|
2
|
+
import extractProp from './extractProp';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Compare two arrays of objects by only comparing the values in a specific
|
|
6
|
+
* property (e.g. compare user arrays by comparing their user.id values)
|
|
7
|
+
* @author Gabe Abrams
|
|
8
|
+
* @param a the first array
|
|
9
|
+
* @param b the second array
|
|
10
|
+
* @param prop the property to compare with
|
|
11
|
+
* @returns true if the arrays contain the same objects as determined by
|
|
12
|
+
* the values associated with each object's prop
|
|
13
|
+
*/
|
|
14
|
+
const compareArraysByProp = (a: any[], b: any[], prop: string): boolean => {
|
|
15
|
+
// Extract values for comparison
|
|
16
|
+
const aVals = new Set(extractProp(a, prop));
|
|
17
|
+
const bVals = new Set(extractProp(b, prop));
|
|
18
|
+
|
|
19
|
+
// Compare sizes first
|
|
20
|
+
if (aVals.size !== bVals.size) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Same number of items. Make sure every object in aVals appears in bVals
|
|
25
|
+
// (if so, they should be equivalent since the sizes are the same)
|
|
26
|
+
// > Create map of items in bVals
|
|
27
|
+
const inBVals: { [k: string]: boolean } = {}; // item => true if in bVals
|
|
28
|
+
Array.from(bVals.values()).forEach((item) => {
|
|
29
|
+
inBVals[item] = true;
|
|
30
|
+
});
|
|
31
|
+
// > Loop through aVals and make sure every item is in bVals
|
|
32
|
+
return Array.from(aVals.values()).every((item) => {
|
|
33
|
+
return inBVals[item];
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default compareArraysByProp;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
const extractProp = (arr: any[], prop: string) => {
|
|
12
|
+
return arr.map((item) => {
|
|
13
|
+
return item[prop];
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default extractProp;
|
package/src/index.ts
CHANGED
|
@@ -60,6 +60,8 @@ import getMonthName from './helpers/getMonthName';
|
|
|
60
60
|
import genCSV from './helpers/genCSV';
|
|
61
61
|
import canReviewLogs from './helpers/canReviewLogs';
|
|
62
62
|
import isMobileOrTablet from './helpers/isMobileOrTablet';
|
|
63
|
+
import extractProp from './helpers/extractProp';
|
|
64
|
+
import compareArraysByProp from './helpers/compareArraysByProp';
|
|
63
65
|
|
|
64
66
|
// Import types
|
|
65
67
|
import ModalButtonType from './types/ModalButtonType';
|
|
@@ -137,6 +139,8 @@ export {
|
|
|
137
139
|
genCSV,
|
|
138
140
|
canReviewLogs,
|
|
139
141
|
isMobileOrTablet,
|
|
142
|
+
extractProp,
|
|
143
|
+
compareArraysByProp,
|
|
140
144
|
// Client helpers
|
|
141
145
|
visitServerEndpoint,
|
|
142
146
|
logClientEvent,
|