expensify-common 2.0.149 → 2.0.150

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.
@@ -2,9 +2,9 @@ export default class ExpenseRule {
2
2
  /**
3
3
  * Creates a new instance of this class.
4
4
  *
5
- * @param {Array} ruleArray
5
+ * @param {Object|Array} ruleArray
6
6
  */
7
- constructor(ruleArray: any[]);
7
+ constructor(ruleArray: Object | any[]);
8
8
  /**
9
9
  * Returns the applyWhen array associated with the passed field
10
10
  * i.e. field == category returns [field: 'category', condition: 'matches', value: 'car']
@@ -4,12 +4,20 @@ class ExpenseRule {
4
4
  /**
5
5
  * Creates a new instance of this class.
6
6
  *
7
- * @param {Array} ruleArray
7
+ * @param {Object|Array} ruleArray
8
8
  */
9
9
  constructor(ruleArray) {
10
- ruleArray.forEach((value, key) => {
11
- this[key] = value;
12
- });
10
+ // It's not 100% certain that `ruleArray` is an array or an object, so support both of them so the app doesn't crash
11
+ if (Array.isArray(ruleArray)) {
12
+ ruleArray.forEach((value, key) => {
13
+ this[key] = value;
14
+ });
15
+ }
16
+ else if (ruleArray && typeof ruleArray === 'object') {
17
+ Object.keys(ruleArray).forEach((key) => {
18
+ this[key] = ruleArray[key];
19
+ });
20
+ }
13
21
  }
14
22
  /**
15
23
  * Returns the applyWhen array associated with the passed field
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expensify-common",
3
- "version": "2.0.149",
3
+ "version": "2.0.150",
4
4
  "author": "Expensify, Inc.",
5
5
  "description": "Expensify libraries and components shared across different repos",
6
6
  "homepage": "https://expensify.com",