expensify-common 2.0.147 → 2.0.149

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/Templates.js CHANGED
@@ -72,7 +72,13 @@ exports.default = (function () {
72
72
  */
73
73
  get(data = {}) {
74
74
  if (!this.compiled) {
75
- this.compiled = (0, template_1.default)(this.templateValue);
75
+ this.compiled = (0, template_1.default)(this.templateValue, {
76
+ imports: {
77
+ // Here we ignore the eslint rule because _ is imported from OD which does not exist in this repo
78
+ // eslint-disable-next-line no-undef, object-shorthand
79
+ _: _,
80
+ },
81
+ });
76
82
  this.templateValue = '';
77
83
  }
78
84
  return this.compiled(data);
@@ -104,7 +110,13 @@ exports.default = (function () {
104
110
  // eslint-disable-next-line no-undef
105
111
  dataToCompile.nestedTemplate = Templates.get;
106
112
  if (!this.compiled) {
107
- this.compiled = (0, template_1.default)((0, jquery_1.default)(`#${this.id}`).html());
113
+ this.compiled = (0, template_1.default)((0, jquery_1.default)(`#${this.id}`).html(), {
114
+ imports: {
115
+ // Here we ignore the eslint rule because _ is imported from OD which does not exist in this repo
116
+ // eslint-disable-next-line no-undef, object-shorthand
117
+ _: _,
118
+ },
119
+ });
108
120
  }
109
121
  return this.compiled(dataToCompile);
110
122
  }
@@ -5,5 +5,5 @@
5
5
  * On native, when merging an existing value with new changes, SQLite will use JSON_PATCH, which removes top-level nullish values.
6
6
  * To be consistent with the behaviour for merge, we'll also want to remove null values for "set" operations.
7
7
  */
8
- declare function fastMerge<TObject>(target: TObject, source: TObject, shouldRemoveNullObjectValues?: boolean): TObject;
8
+ declare function fastMerge<TObject extends Record<string, unknown>>(target: TObject, source: TObject, shouldRemoveNullObjectValues?: boolean): TObject;
9
9
  export default fastMerge;
package/dist/fastMerge.js CHANGED
@@ -11,13 +11,20 @@ function isMergeableObject(value) {
11
11
  return nonNullObject && Object.prototype.toString.call(value) !== '[object RegExp]' && Object.prototype.toString.call(value) !== '[object Date]' && !Array.isArray(value);
12
12
  }
13
13
  /**
14
- * Merges the source object into the target object.
15
- * @param target - The target object.
16
- * @param source - The source object.
17
- * @param shouldRemoveNestedNulls - If true, null object values will be removed.
18
- * @returns - The merged object.
14
+ * Merges two objects and removes null values if "shouldRemoveNullObjectValues" is set to true
15
+ *
16
+ * We generally want to remove null values from objects written to disk and cache, because it decreases the amount of data stored in memory and on disk.
17
+ * On native, when merging an existing value with new changes, SQLite will use JSON_PATCH, which removes top-level nullish values.
18
+ * To be consistent with the behaviour for merge, we'll also want to remove null values for "set" operations.
19
19
  */
20
- function mergeObject(target, source, shouldRemoveNullObjectValues = true) {
20
+ function fastMerge(target, source, shouldRemoveNullObjectValues = true) {
21
+ // We have to ignore arrays and nullish values here,
22
+ // otherwise "mergeObject" will throw an error,
23
+ // because it expects an object as "source"
24
+ if (Array.isArray(source) || source === null || source === undefined) {
25
+ return source;
26
+ }
27
+ // Merges the source object into the target object.
21
28
  const destination = {};
22
29
  if (isMergeableObject(target)) {
23
30
  // lodash adds a small overhead so we don't use it here
@@ -59,20 +66,4 @@ function mergeObject(target, source, shouldRemoveNullObjectValues = true) {
59
66
  }
60
67
  return destination;
61
68
  }
62
- /**
63
- * Merges two objects and removes null values if "shouldRemoveNullObjectValues" is set to true
64
- *
65
- * We generally want to remove null values from objects written to disk and cache, because it decreases the amount of data stored in memory and on disk.
66
- * On native, when merging an existing value with new changes, SQLite will use JSON_PATCH, which removes top-level nullish values.
67
- * To be consistent with the behaviour for merge, we'll also want to remove null values for "set" operations.
68
- */
69
- function fastMerge(target, source, shouldRemoveNullObjectValues = true) {
70
- // We have to ignore arrays and nullish values here,
71
- // otherwise "mergeObject" will throw an error,
72
- // because it expects an object as "source"
73
- if (Array.isArray(source) || source === null || source === undefined) {
74
- return source;
75
- }
76
- return mergeObject(target, source, shouldRemoveNullObjectValues);
77
- }
78
69
  exports.default = fastMerge;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expensify-common",
3
- "version": "2.0.147",
3
+ "version": "2.0.149",
4
4
  "author": "Expensify, Inc.",
5
5
  "description": "Expensify libraries and components shared across different repos",
6
6
  "homepage": "https://expensify.com",