@bigbinary/neeto-commons-frontend 2.0.4 → 2.0.7

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/README.md CHANGED
@@ -7,7 +7,7 @@ The commons frontend library for Neeto Applications.
7
7
  Install from npm:
8
8
 
9
9
  ```bash
10
- yarn add "@bigbinary/neeto-commons-frontend@2.0.4"
10
+ yarn add "@bigbinary/neeto-commons-frontend@2.0.7"
11
11
  ```
12
12
 
13
13
  This package relies on the host project's tailwind configuration. So add
@@ -2,12 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ramda = require('ramda');
6
5
  var neetoui = require('@bigbinary/neetoui');
7
6
  var axios = require('axios');
8
7
  var i18next = require('i18next');
9
- var mixpanel = require('mixpanel-browser');
8
+ var ramda = require('ramda');
10
9
  var reactI18next = require('react-i18next');
10
+ var mixpanel = require('mixpanel-browser');
11
11
 
12
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
13
 
@@ -25,6 +25,21 @@ function _typeof(obj) {
25
25
  }, _typeof(obj);
26
26
  }
27
27
 
28
+ function _defineProperty(obj, key, value) {
29
+ if (key in obj) {
30
+ Object.defineProperty(obj, key, {
31
+ value: value,
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true
35
+ });
36
+ } else {
37
+ obj[key] = value;
38
+ }
39
+
40
+ return obj;
41
+ }
42
+
28
43
  function _arrayWithHoles(arr) {
29
44
  if (Array.isArray(arr)) return arr;
30
45
  }
@@ -120,19 +135,20 @@ var keysToCamelCase = function keysToCamelCase(object) {
120
135
  });
121
136
  };
122
137
  var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
123
- if (Array.isArray(object)) {
124
- return object.map(serializeKeysToSnakeCase);
125
- } else if (object === null || _typeof(object) !== "object") {
126
- return object;
138
+ var serializedObj = typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
139
+
140
+ if (Array.isArray(serializedObj)) {
141
+ return serializedObj.map(serializeKeysToSnakeCase);
142
+ } else if (serializedObj === null || _typeof(serializedObj) !== "object") {
143
+ return serializedObj;
127
144
  }
128
145
 
129
- return Object.fromEntries(Object.entries(object).map(function (_ref3) {
146
+ return Object.fromEntries(Object.entries(serializedObj).map(function (_ref3) {
130
147
  var _ref4 = _slicedToArray(_ref3, 2),
131
148
  key = _ref4[0],
132
149
  value = _ref4[1];
133
150
 
134
- var val = typeof (value === null || value === void 0 ? void 0 : value.toJSON) === "function" ? value.toJSON() : value;
135
- return [camelToSnakeCase(key), serializeKeysToSnakeCase(val)];
151
+ return [camelToSnakeCase(key), serializeKeysToSnakeCase(value)];
136
152
  }));
137
153
  };
138
154
  var deepFreezeObject = function deepFreezeObject(object) {
@@ -145,43 +161,6 @@ var deepFreezeObject = function deepFreezeObject(object) {
145
161
 
146
162
  return object;
147
163
  };
148
- var matches = ramda.curry(function (pattern, object) {
149
- var __parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
150
-
151
- if (object === pattern) return true;
152
- if (typeof pattern === "function" && pattern(object, __parent)) return true;
153
- if (ramda.isNil(pattern) || ramda.isNil(object)) return false;
154
- if (_typeof(pattern) !== "object") return false;
155
- return Object.entries(pattern).every(function (_ref5) {
156
- var _ref6 = _slicedToArray(_ref5, 2),
157
- key = _ref6[0],
158
- value = _ref6[1];
159
-
160
- return matches(value, object[key], __parent);
161
- });
162
- });
163
-
164
- function initializeGlobalProps() {
165
- var _document$getElements, _document$getElements2;
166
-
167
- window.globalProps = keysToCamelCase(JSON.parse(((_document$getElements = document.getElementsByClassName("root-container")[0]) === null || _document$getElements === void 0 ? void 0 : (_document$getElements2 = _document$getElements.dataset) === null || _document$getElements2 === void 0 ? void 0 : _document$getElements2.reactProps) || "{}"));
168
- deepFreezeObject(window.globalProps);
169
- }
170
-
171
- function _defineProperty(obj, key, value) {
172
- if (key in obj) {
173
- Object.defineProperty(obj, key, {
174
- value: value,
175
- enumerable: true,
176
- configurable: true,
177
- writable: true
178
- });
179
- } else {
180
- obj[key] = value;
181
- }
182
-
183
- return obj;
184
- }
185
164
 
186
165
  var HEADERS_KEYS = {
187
166
  xAuthEmail: "X-Auth-Email",
@@ -280,6 +259,10 @@ var handleUnauthorizedErrorResponse = function handleUnauthorizedErrorResponse(e
280
259
  };
281
260
 
282
261
  var showErrorToastr = function showErrorToastr(error) {
262
+ var _error$config$showToa = error.config.showToastr,
263
+ showToastr = _error$config$showToa === void 0 ? true : _error$config$showToa;
264
+ if (!showToastr) return error;
265
+
283
266
  if (axios__default["default"].isCancel(error)) {
284
267
  neetoui.Toastr.error(i18next__default["default"].t("neetoCommons.toastr.error.requestCanceled"));
285
268
  } else if (error.message === "Network Error") {
@@ -353,26 +336,11 @@ function initializeAxios(skip) {
353
336
  if (shouldNot(skip === null || skip === void 0 ? void 0 : skip.interceptors)) registerIntercepts(skip === null || skip === void 0 ? void 0 : skip.interceptors);
354
337
  }
355
338
 
356
- function initializeMixPanel() {
357
- var isProduction = process.env.NODE_ENV === "production";
358
- var isTokenPresent = !!process.env.MIXPANEL_TOKEN;
359
- var isUserLoggedIn = !ramda.either(ramda.isEmpty, ramda.isNil)(globalProps.user);
339
+ function initializeGlobalProps() {
340
+ var _document$getElements, _document$getElements2;
360
341
 
361
- if (isProduction && isTokenPresent && isUserLoggedIn) {
362
- mixpanel__default["default"].init(process.env.MIXPANEL_TOKEN || "");
363
- mixpanel__default["default"].people.set({
364
- $email: globalProps.user.email,
365
- $fist_name: globalProps.user.firstName,
366
- $last_name: globalProps.user.lastName
367
- });
368
- mixpanel__default["default"].identify(globalProps.user.email);
369
- } else {
370
- /*
371
- We need to initialize mixpanel with a bogus token in development and test environment to
372
- prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
373
- */
374
- mixpanel__default["default"].init("TEST_TOKEN");
375
- }
342
+ window.globalProps = keysToCamelCase(JSON.parse(((_document$getElements = document.getElementsByClassName("root-container")[0]) === null || _document$getElements === void 0 ? void 0 : (_document$getElements2 = _document$getElements.dataset) === null || _document$getElements2 === void 0 ? void 0 : _document$getElements2.reactProps) || "{}"));
343
+ deepFreezeObject(window.globalProps);
376
344
  }
377
345
 
378
346
  var neetoCommons = {
@@ -386,8 +354,8 @@ var neetoCommons = {
386
354
  reload: "Reload"
387
355
  },
388
356
  sidebar: {
389
- profile: "Profile",
390
- orgSettings: "Organization Settings",
357
+ myProfile: "My Profile",
358
+ myOrganization: "My Organization",
391
359
  logout: "Logout",
392
360
  help: "Help"
393
361
  },
@@ -430,6 +398,28 @@ var initializeI18n = function initializeI18n(resources) {
430
398
  });
431
399
  };
432
400
 
401
+ function initializeMixPanel() {
402
+ var isProduction = process.env.NODE_ENV === "production";
403
+ var isTokenPresent = !!process.env.MIXPANEL_TOKEN;
404
+ var isUserLoggedIn = !ramda.either(ramda.isEmpty, ramda.isNil)(globalProps.user);
405
+
406
+ if (isProduction && isTokenPresent && isUserLoggedIn) {
407
+ mixpanel__default["default"].init(process.env.MIXPANEL_TOKEN || "");
408
+ mixpanel__default["default"].people.set({
409
+ $email: globalProps.user.email,
410
+ $fist_name: globalProps.user.firstName,
411
+ $last_name: globalProps.user.lastName
412
+ });
413
+ mixpanel__default["default"].identify(globalProps.user.email);
414
+ } else {
415
+ /*
416
+ We need to initialize mixpanel with a bogus token in development and test environment to
417
+ prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
418
+ */
419
+ mixpanel__default["default"].init("TEST_TOKEN");
420
+ }
421
+ }
422
+
433
423
  exports.globalProps = {};
434
424
  function initializeApplication(_ref) {
435
425
  var translationResources = _ref.translationResources,
package/initializers.js CHANGED
@@ -1,9 +1,9 @@
1
- import { curry, isNil, values, evolve, omit, modify, either, isEmpty, mergeDeepLeft } from 'ramda';
2
1
  import { Toastr } from '@bigbinary/neetoui';
3
2
  import axios from 'axios';
4
3
  import i18next from 'i18next';
5
- import mixpanel from 'mixpanel-browser';
4
+ import { values, evolve, omit, modify, mergeDeepLeft, either, isEmpty, isNil } from 'ramda';
6
5
  import { initReactI18next } from 'react-i18next';
6
+ import mixpanel from 'mixpanel-browser';
7
7
 
8
8
  function _typeof(obj) {
9
9
  "@babel/helpers - typeof";
@@ -15,6 +15,21 @@ function _typeof(obj) {
15
15
  }, _typeof(obj);
16
16
  }
17
17
 
18
+ function _defineProperty(obj, key, value) {
19
+ if (key in obj) {
20
+ Object.defineProperty(obj, key, {
21
+ value: value,
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true
25
+ });
26
+ } else {
27
+ obj[key] = value;
28
+ }
29
+
30
+ return obj;
31
+ }
32
+
18
33
  function _arrayWithHoles(arr) {
19
34
  if (Array.isArray(arr)) return arr;
20
35
  }
@@ -110,19 +125,20 @@ var keysToCamelCase = function keysToCamelCase(object) {
110
125
  });
111
126
  };
112
127
  var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
113
- if (Array.isArray(object)) {
114
- return object.map(serializeKeysToSnakeCase);
115
- } else if (object === null || _typeof(object) !== "object") {
116
- return object;
128
+ var serializedObj = typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
129
+
130
+ if (Array.isArray(serializedObj)) {
131
+ return serializedObj.map(serializeKeysToSnakeCase);
132
+ } else if (serializedObj === null || _typeof(serializedObj) !== "object") {
133
+ return serializedObj;
117
134
  }
118
135
 
119
- return Object.fromEntries(Object.entries(object).map(function (_ref3) {
136
+ return Object.fromEntries(Object.entries(serializedObj).map(function (_ref3) {
120
137
  var _ref4 = _slicedToArray(_ref3, 2),
121
138
  key = _ref4[0],
122
139
  value = _ref4[1];
123
140
 
124
- var val = typeof (value === null || value === void 0 ? void 0 : value.toJSON) === "function" ? value.toJSON() : value;
125
- return [camelToSnakeCase(key), serializeKeysToSnakeCase(val)];
141
+ return [camelToSnakeCase(key), serializeKeysToSnakeCase(value)];
126
142
  }));
127
143
  };
128
144
  var deepFreezeObject = function deepFreezeObject(object) {
@@ -135,43 +151,6 @@ var deepFreezeObject = function deepFreezeObject(object) {
135
151
 
136
152
  return object;
137
153
  };
138
- var matches = curry(function (pattern, object) {
139
- var __parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
140
-
141
- if (object === pattern) return true;
142
- if (typeof pattern === "function" && pattern(object, __parent)) return true;
143
- if (isNil(pattern) || isNil(object)) return false;
144
- if (_typeof(pattern) !== "object") return false;
145
- return Object.entries(pattern).every(function (_ref5) {
146
- var _ref6 = _slicedToArray(_ref5, 2),
147
- key = _ref6[0],
148
- value = _ref6[1];
149
-
150
- return matches(value, object[key], __parent);
151
- });
152
- });
153
-
154
- function initializeGlobalProps() {
155
- var _document$getElements, _document$getElements2;
156
-
157
- window.globalProps = keysToCamelCase(JSON.parse(((_document$getElements = document.getElementsByClassName("root-container")[0]) === null || _document$getElements === void 0 ? void 0 : (_document$getElements2 = _document$getElements.dataset) === null || _document$getElements2 === void 0 ? void 0 : _document$getElements2.reactProps) || "{}"));
158
- deepFreezeObject(window.globalProps);
159
- }
160
-
161
- function _defineProperty(obj, key, value) {
162
- if (key in obj) {
163
- Object.defineProperty(obj, key, {
164
- value: value,
165
- enumerable: true,
166
- configurable: true,
167
- writable: true
168
- });
169
- } else {
170
- obj[key] = value;
171
- }
172
-
173
- return obj;
174
- }
175
154
 
176
155
  var HEADERS_KEYS = {
177
156
  xAuthEmail: "X-Auth-Email",
@@ -270,6 +249,10 @@ var handleUnauthorizedErrorResponse = function handleUnauthorizedErrorResponse(e
270
249
  };
271
250
 
272
251
  var showErrorToastr = function showErrorToastr(error) {
252
+ var _error$config$showToa = error.config.showToastr,
253
+ showToastr = _error$config$showToa === void 0 ? true : _error$config$showToa;
254
+ if (!showToastr) return error;
255
+
273
256
  if (axios.isCancel(error)) {
274
257
  Toastr.error(i18next.t("neetoCommons.toastr.error.requestCanceled"));
275
258
  } else if (error.message === "Network Error") {
@@ -343,26 +326,11 @@ function initializeAxios(skip) {
343
326
  if (shouldNot(skip === null || skip === void 0 ? void 0 : skip.interceptors)) registerIntercepts(skip === null || skip === void 0 ? void 0 : skip.interceptors);
344
327
  }
345
328
 
346
- function initializeMixPanel() {
347
- var isProduction = process.env.NODE_ENV === "production";
348
- var isTokenPresent = !!process.env.MIXPANEL_TOKEN;
349
- var isUserLoggedIn = !either(isEmpty, isNil)(globalProps.user);
329
+ function initializeGlobalProps() {
330
+ var _document$getElements, _document$getElements2;
350
331
 
351
- if (isProduction && isTokenPresent && isUserLoggedIn) {
352
- mixpanel.init(process.env.MIXPANEL_TOKEN || "");
353
- mixpanel.people.set({
354
- $email: globalProps.user.email,
355
- $fist_name: globalProps.user.firstName,
356
- $last_name: globalProps.user.lastName
357
- });
358
- mixpanel.identify(globalProps.user.email);
359
- } else {
360
- /*
361
- We need to initialize mixpanel with a bogus token in development and test environment to
362
- prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
363
- */
364
- mixpanel.init("TEST_TOKEN");
365
- }
332
+ window.globalProps = keysToCamelCase(JSON.parse(((_document$getElements = document.getElementsByClassName("root-container")[0]) === null || _document$getElements === void 0 ? void 0 : (_document$getElements2 = _document$getElements.dataset) === null || _document$getElements2 === void 0 ? void 0 : _document$getElements2.reactProps) || "{}"));
333
+ deepFreezeObject(window.globalProps);
366
334
  }
367
335
 
368
336
  var neetoCommons = {
@@ -376,8 +344,8 @@ var neetoCommons = {
376
344
  reload: "Reload"
377
345
  },
378
346
  sidebar: {
379
- profile: "Profile",
380
- orgSettings: "Organization Settings",
347
+ myProfile: "My Profile",
348
+ myOrganization: "My Organization",
381
349
  logout: "Logout",
382
350
  help: "Help"
383
351
  },
@@ -420,6 +388,28 @@ var initializeI18n = function initializeI18n(resources) {
420
388
  });
421
389
  };
422
390
 
391
+ function initializeMixPanel() {
392
+ var isProduction = process.env.NODE_ENV === "production";
393
+ var isTokenPresent = !!process.env.MIXPANEL_TOKEN;
394
+ var isUserLoggedIn = !either(isEmpty, isNil)(globalProps.user);
395
+
396
+ if (isProduction && isTokenPresent && isUserLoggedIn) {
397
+ mixpanel.init(process.env.MIXPANEL_TOKEN || "");
398
+ mixpanel.people.set({
399
+ $email: globalProps.user.email,
400
+ $fist_name: globalProps.user.firstName,
401
+ $last_name: globalProps.user.lastName
402
+ });
403
+ mixpanel.identify(globalProps.user.email);
404
+ } else {
405
+ /*
406
+ We need to initialize mixpanel with a bogus token in development and test environment to
407
+ prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
408
+ */
409
+ mixpanel.init("TEST_TOKEN");
410
+ }
411
+ }
412
+
423
413
  var globalProps$1 = {};
424
414
  function initializeApplication(_ref) {
425
415
  var translationResources = _ref.translationResources,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "2.0.4",
3
+ "version": "2.0.7",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",
@@ -47,7 +47,7 @@
47
47
  "@babel/preset-env": "^7.17.10",
48
48
  "@babel/preset-react": "^7.16.7",
49
49
  "@bigbinary/neeto-icons": "^1.8.35",
50
- "@bigbinary/neetoui": "^3.5.14",
50
+ "@bigbinary/neetoui": "^3.5.16",
51
51
  "@honeybadger-io/react": "2.0.1",
52
52
  "@rollup/plugin-alias": "^3.1.9",
53
53
  "@rollup/plugin-babel": "^5.3.1",
@@ -96,7 +96,7 @@
96
96
  "dependencies": {},
97
97
  "peerDependencies": {
98
98
  "@bigbinary/neeto-icons": "^1.8.35",
99
- "@bigbinary/neetoui": "^3.5.14",
99
+ "@bigbinary/neetoui": "^3.5.16",
100
100
  "@honeybadger-io/react": "2.0.1",
101
101
  "axios": "^0.27.2",
102
102
  "dayjs": "1.11.1",
package/pure.cjs.js CHANGED
@@ -134,19 +134,20 @@ var keysToSnakeCase = function keysToSnakeCase(object) {
134
134
  });
135
135
  };
136
136
  var serializeKeysToSnakeCase = function serializeKeysToSnakeCase(object) {
137
- if (Array.isArray(object)) {
138
- return object.map(serializeKeysToSnakeCase);
139
- } else if (object === null || _typeof(object) !== "object") {
140
- return object;
137
+ var serializedObj = typeof (object === null || object === void 0 ? void 0 : object.toJSON) === "function" ? object.toJSON() : object;
138
+
139
+ if (Array.isArray(serializedObj)) {
140
+ return serializedObj.map(serializeKeysToSnakeCase);
141
+ } else if (serializedObj === null || _typeof(serializedObj) !== "object") {
142
+ return serializedObj;
141
143
  }
142
144
 
143
- return Object.fromEntries(Object.entries(object).map(function (_ref3) {
145
+ return Object.fromEntries(Object.entries(serializedObj).map(function (_ref3) {
144
146
  var _ref4 = _slicedToArray(_ref3, 2),
145
147
  key = _ref4[0],
146
148
  value = _ref4[1];
147
149
 
148
- var val = typeof (value === null || value === void 0 ? void 0 : value.toJSON) === "function" ? value.toJSON() : value;
149
- return [camelToSnakeCase(key), serializeKeysToSnakeCase(val)];
150
+ return [camelToSnakeCase(key), serializeKeysToSnakeCase(value)];
150
151
  }));
151
152
  };
152
153
  var deepFreezeObject = function deepFreezeObject(object) {
@@ -159,7 +160,7 @@ var deepFreezeObject = function deepFreezeObject(object) {
159
160
 
160
161
  return object;
161
162
  };
162
- var matches = ramda.curry(function (pattern, object) {
163
+ var matches = /*#__PURE__*/ramda.curry(function (pattern, object) {
163
164
  var __parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
164
165
 
165
166
  if (object === pattern) return true;
@@ -207,71 +208,71 @@ function _defineProperty(obj, key, value) {
207
208
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
208
209
 
209
210
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
210
- var removeById = ramda.curry(function (id, array) {
211
+ var removeById = /*#__PURE__*/ramda.curry(function (id, array) {
211
212
  return array.filter(function (item) {
212
213
  return item.id !== id;
213
214
  });
214
215
  });
215
- var findById = ramda.curry(function (id, array) {
216
+ var findById = /*#__PURE__*/ramda.curry(function (id, array) {
216
217
  return array.find(function (item) {
217
218
  return item.id === id;
218
219
  });
219
220
  });
220
- var replaceById = ramda.curry(function (id, newItem, array) {
221
+ var replaceById = /*#__PURE__*/ramda.curry(function (id, newItem, array) {
221
222
  return array.map(function (item) {
222
223
  return item.id === id ? newItem : item;
223
224
  });
224
225
  });
225
- var modifyById = ramda.curry(function (id, modifier, array) {
226
+ var modifyById = /*#__PURE__*/ramda.curry(function (id, modifier, array) {
226
227
  return array.map(function (item) {
227
228
  return item.id === id ? modifier(item) : item;
228
229
  });
229
230
  });
230
- var findBy = ramda.curry(function (pattern, array) {
231
+ var findBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
231
232
  return array.find(matches(pattern));
232
233
  });
233
- var removeBy = ramda.curry(function (pattern, array) {
234
+ var removeBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
234
235
  return array.filter(ramda.complement(matches(pattern)));
235
236
  });
236
- var replaceBy = ramda.curry(function (pattern, newItem, array) {
237
+ var replaceBy = /*#__PURE__*/ramda.curry(function (pattern, newItem, array) {
237
238
  return array.map(function (item) {
238
239
  return matches(pattern, item) ? newItem : item;
239
240
  });
240
241
  });
241
- var modifyBy = ramda.curry(function (pattern, modifier, array) {
242
+ var modifyBy = /*#__PURE__*/ramda.curry(function (pattern, modifier, array) {
242
243
  return array.map(function (item) {
243
244
  return matches(pattern, item) ? modifier(item) : item;
244
245
  });
245
246
  });
246
- var existsById = ramda.curry(function (id, array) {
247
+ var existsById = /*#__PURE__*/ramda.curry(function (id, array) {
247
248
  return array.some(function (item) {
248
249
  return item.id === id;
249
250
  });
250
251
  });
251
- var existsBy = ramda.curry(function (pattern, array) {
252
+ var existsBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
252
253
  return array.some(matches(pattern));
253
254
  });
254
- var findLastBy = ramda.curry(function (pattern, array) {
255
+ var findLastBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
255
256
  return ramda.findLast(matches(pattern), array);
256
257
  });
257
- var findIndexById = ramda.curry(function (id, array) {
258
+ var findIndexById = /*#__PURE__*/ramda.curry(function (id, array) {
258
259
  return array.findIndex(function (item) {
259
260
  return item.id === id;
260
261
  });
261
262
  });
262
- var findIndexBy = ramda.curry(function (pattern, array) {
263
+ var findIndexBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
263
264
  return array.findIndex(matches(pattern));
264
265
  });
265
- var findLastIndexBy = ramda.curry(function (pattern, array) {
266
+ var findLastIndexBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
266
267
  return ramda.findLastIndex(matches(pattern), array);
267
268
  });
268
- var filterBy = ramda.curry(function (pattern, array) {
269
+ var filterBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
269
270
  return array.filter(matches(pattern));
270
271
  });
271
- var countBy = ramda.curry(function (pattern, array) {
272
+ var countBy = /*#__PURE__*/ramda.curry(function (pattern, array) {
272
273
  return ramda.count(matches(pattern), array);
273
274
  });
274
- var copyKeys = ramda.curry(function (keyMap, objectArray) {
275
+ var copyKeys = /*#__PURE__*/ramda.curry(function (keyMap, objectArray) {
275
276
  return objectArray.map(function (object) {
276
277
  var shallowCopy = _objectSpread({}, object);
277
278
 
@@ -282,7 +283,7 @@ var copyKeys = ramda.curry(function (keyMap, objectArray) {
282
283
  return shallowCopy;
283
284
  });
284
285
  });
285
- var renameKeys = ramda.curry(function (keyMap, objectArray) {
286
+ var renameKeys = /*#__PURE__*/ramda.curry(function (keyMap, objectArray) {
286
287
  return objectArray.map(function (object) {
287
288
  var shallowCopy = _objectSpread({}, object);
288
289
 
@@ -294,7 +295,7 @@ var renameKeys = ramda.curry(function (keyMap, objectArray) {
294
295
  return shallowCopy;
295
296
  });
296
297
  });
297
- var copyKeysDeep = ramda.curry(function (keyMap, objectArray) {
298
+ var copyKeysDeep = /*#__PURE__*/ramda.curry(function (keyMap, objectArray) {
298
299
  var copyKeysSingleObject = function copyKeysSingleObject(object, keyMap) {
299
300
  var root = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
300
301
  return _objectSpread(_objectSpread({}, object), ramda.fromPairs(ramda.toPairs(keyMap).map(function (_ref) {
@@ -355,13 +356,13 @@ var dynamicArray = function dynamicArray(count, elementGenerator) {
355
356
  return elementGenerator(index);
356
357
  });
357
358
  };
358
- var isNotNil = ramda.complement(ramda.isNil);
359
- var isNotEmpty = ramda.complement(ramda.isEmpty);
360
- var notEquals = ramda.curry(function (x, y) {
359
+ var isNotNil = /*#__PURE__*/ramda.complement(ramda.isNil);
360
+ var isNotEmpty = /*#__PURE__*/ramda.complement(ramda.isEmpty);
361
+ var notEquals = /*#__PURE__*/ramda.curry(function (x, y) {
361
362
  return x !== y;
362
363
  });
363
364
  var isNot = notEquals;
364
- var notEqualsDeep = ramda.complement(ramda.equals);
365
+ var notEqualsDeep = /*#__PURE__*/ramda.complement(ramda.equals);
365
366
  var isNotEqualDeep = notEqualsDeep;
366
367
 
367
368
  exports.camelToSnakeCase = camelToSnakeCase;
package/pure.d.ts CHANGED
@@ -1,23 +1,24 @@
1
- export type ObjectAndPrimitives =
2
- | object
3
- | symbol
4
- | string
5
- | number
6
- | boolean
7
- | null
8
- | undefined;
9
-
10
- type MatchPattern<Obj = any, Parent = Obj> = {
11
- [key in keyof Partial<Obj>]:
12
- | ((object: Obj[key], parent: Parent) => boolean)
13
- | MatchPattern<Obj[key], Parent>
14
- | ObjectAndPrimitives;
15
- } & {
16
- [key: string | number | symbol]:
17
- | ((object: any, parent: Parent) => boolean)
18
- | MatchPattern<any, Parent>
19
- | ObjectAndPrimitives;
20
- };
1
+ export type Primitives = symbol | string | number | boolean | null | undefined;
2
+ export type ObjectAndPrimitives = Primitives | object;
3
+ type KeyType = string | number | symbol;
4
+
5
+ type Matchable<Obj, Parent, key extends keyof Obj> =
6
+ | ((object: Obj[key], parent: Parent) => boolean)
7
+ | MatchPattern<Obj[key], Parent>
8
+ | Primitives;
9
+
10
+ type MatchPattern<Obj = any, Parent = Obj> = Obj extends any[]
11
+ ?
12
+ | Matchable<Obj, Parent, number>[]
13
+ | { [key: number]: Matchable<Obj, Parent, number> }
14
+ : Obj extends Primitives
15
+ ? Obj
16
+ :
17
+ | {
18
+ [key in keyof Partial<Obj>]: Matchable<Obj, Parent, key>;
19
+ } & {
20
+ [key: KeyType]: Matchable<any, Parent, KeyType>;
21
+ };
21
22
 
22
23
  export function camelToSnakeCase(string: string): string;
23
24
  export function capitalize(string: string): string;