@builttocreate/engine-utils 1.4.2 → 1.5.0

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.js CHANGED
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "CALL_API", {
17
17
  return _reduxApiMiddleware.CALL_API;
18
18
  }
19
19
  });
20
- exports.activityHelper = exports.fieldHelper = exports.chartHelper = exports.tableHelper = exports["default"] = void 0;
20
+ exports.paginationHelper = exports.activityHelper = exports.fieldHelper = exports.chartHelper = exports.tableHelper = exports["default"] = void 0;
21
21
 
22
22
  var tableHelper = _interopRequireWildcard(require("./tableHelper"));
23
23
 
@@ -37,12 +37,16 @@ exports.activityHelper = activityHelper;
37
37
 
38
38
  var _reduxApiMiddleware = _interopRequireWildcard(require("./reduxApiMiddleware"));
39
39
 
40
+ var paginationHelper = _interopRequireWildcard(require("./paginationHelper"));
41
+
42
+ exports.paginationHelper = paginationHelper;
40
43
  var _default = {
41
44
  tableHelper: tableHelper,
42
45
  chartHelper: chartHelper,
43
46
  fieldHelper: fieldHelper,
44
47
  activityHelper: activityHelper,
45
48
  reduxApiMiddleware: _reduxApiMiddleware["default"],
46
- CALL_API: _reduxApiMiddleware.CALL_API
49
+ CALL_API: _reduxApiMiddleware.CALL_API,
50
+ paginationHelper: paginationHelper
47
51
  };
48
52
  exports["default"] = _default;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = exports.normalizeArray = void 0;
7
+
8
+ /**
9
+ * Normalize an array of objects
10
+ *
11
+ * @param {String|Func} key
12
+ * @param {Array} array
13
+ * @param {Function} keyExtractor //optional
14
+ *
15
+ * Example Input:
16
+ * param key = 'name';
17
+ * param array = [{name: 'frank', age: 19}, {name: 'joe', age: 22}, {name: 'bob', age: 44}]
18
+ *
19
+ * Example return:
20
+ * {
21
+ * 'frank': {name: 'frank', age: 19} ,
22
+ * 'joe': {name: 'joe', age: 22} ,
23
+ * 'bob': {name: 'bob', age: 44} ,
24
+ * }
25
+ */
26
+ var normalizeArray = function normalizeArray(key, array) {
27
+ var obj = {};
28
+ array.forEach(function (e) {
29
+ var objectKey = typeof key === 'function' ? key(e) : e[key];
30
+ obj[objectKey] = e;
31
+ });
32
+ return obj;
33
+ };
34
+
35
+ exports.normalizeArray = normalizeArray;
36
+ var _default = {
37
+ normalizeArray: normalizeArray
38
+ };
39
+ exports["default"] = _default;
@@ -23,7 +23,7 @@ var callApiMiddleware = function callApiMiddleware(_ref) {
23
23
  getState = _ref.getState;
24
24
 
25
25
  /**
26
- * @param next //Callback for the action
26
+ * @param next //Callback for the action
27
27
  * @param action //Action object
28
28
  *
29
29
  * async action example: {
@@ -37,7 +37,7 @@ var callApiMiddleware = function callApiMiddleware(_ref) {
37
37
  */
38
38
  return function (next) {
39
39
  return function (action) {
40
- var callApi = action[CALL_API]; //If callApi is not defined then it is a normal action (synchronous) pass it through
40
+ var callApi = action[CALL_API]; //If callApi is not defined then it is a normal action (synchronous) pass it through
41
41
 
42
42
  if (typeof callApi === 'undefined') return next(action);
43
43
  var types = callApi.types,
@@ -51,7 +51,7 @@ var callApiMiddleware = function callApiMiddleware(_ref) {
51
51
  * All async actions should have three action types: requested, success, & failure
52
52
  * All actions should be strings.
53
53
  *
54
- * apiCall:
54
+ * apiCall:
55
55
  * All aysnc actions should have an apiCall function
56
56
  */
57
57
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builttocreate/engine-utils",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "description": "Utility library for common logic shared across web and mobile",
5
5
  "main": "dist/index.js",
6
6
  "files": [