@becollective/utils 1.5.0 → 1.5.2

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/bundle.js CHANGED
@@ -172,6 +172,22 @@ var getTimeInfo = function getTimeInfo(opportunityUser) {
172
172
  return fields;
173
173
  };
174
174
 
175
+ /**
176
+ *
177
+ * @param {Array} locationList
178
+ */
179
+ var getHomeLocalityFromLocationList = function getHomeLocalityFromLocationList(locationList) {
180
+ var homeLocation = Array.isArray(locationList) && locationList.find(function (location) {
181
+ return location.name === 'Home';
182
+ });
183
+
184
+ if (homeLocation && homeLocation.locality && homeLocation.locality.long) {
185
+ return homeLocation.locality.long;
186
+ }
187
+
188
+ return null;
189
+ };
190
+
175
191
  var util = {
176
192
  getAge: getAge,
177
193
  getCurrencyFromCurrencyCode: getCurrencyFromCurrencyCode,
@@ -182,6 +198,7 @@ var util = {
182
198
  datesByThemselves: datesByThemselves
183
199
  },
184
200
  readableOpportunityType: readableOpportunityType,
185
- getTimeInfo: getTimeInfo
201
+ getTimeInfo: getTimeInfo,
202
+ getHomeLocalityFromLocationList: getHomeLocalityFromLocationList
186
203
  };
187
204
  module.exports = util;
package/index.js CHANGED
@@ -3,6 +3,7 @@ import { isUnderSixteen, getAge, datesByThemselves } from './src/date-time';
3
3
  import { getCurrencyFromCurrencyCode, makeMoneyString } from './src/money';
4
4
  import { readableOpportunityType } from './src/opportunity';
5
5
  import { getTimeInfo } from './src/opportunityUser';
6
+ import { getHomeLocalityFromLocationList } from './src/locality';
6
7
 
7
8
  const util = {
8
9
  getAge,
@@ -15,6 +16,7 @@ const util = {
15
16
  },
16
17
  readableOpportunityType,
17
18
  getTimeInfo,
19
+ getHomeLocalityFromLocationList,
18
20
  };
19
21
 
20
22
  module.exports = util;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@becollective/utils",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "Common utilities",
5
5
  "main": "bundle.js",
6
6
  "scripts": {
@@ -0,0 +1,14 @@
1
+ /**
2
+ *
3
+ * @param {Array} locationList
4
+ */
5
+ export const getHomeLocalityFromLocationList = (locationList) => {
6
+ const homeLocation = Array.isArray(locationList) &&
7
+ locationList.find((location) => location.name === 'Home');
8
+
9
+ if (homeLocation && homeLocation.locality && homeLocation.locality.long) {
10
+ return homeLocation.locality.long;
11
+ }
12
+
13
+ return null;
14
+ };