expensify-common 2.0.146 → 2.0.148

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.
@@ -155,7 +155,7 @@ export default class ExpensiMark {
155
155
  /**
156
156
  * Replaces HTML with markdown
157
157
  */
158
- htmlToMarkdown(htmlString: string, extras?: Extras, maxBodyLength?: number): string;
158
+ htmlToMarkdown(htmlString: string, extras?: Extras): string;
159
159
  /**
160
160
  * Convert HTML to text
161
161
  */
@@ -1051,7 +1051,7 @@ class ExpensiMark {
1051
1051
  /**
1052
1052
  * Replaces HTML with markdown
1053
1053
  */
1054
- htmlToMarkdown(htmlString, extras = EXTRAS_DEFAULT, maxBodyLength = 0) {
1054
+ htmlToMarkdown(htmlString, extras = EXTRAS_DEFAULT) {
1055
1055
  let generatedMarkdown = htmlString;
1056
1056
  const body = /<(body)(?:"[^"]*"|'[^']*'|[^'"><])*>(?:\n|\r\n)?([\s\S]*?)(?:\n|\r\n)?<\/\1>(?![^<]*(<\/pre>|<\/code>))/im;
1057
1057
  const parseBodyTag = generatedMarkdown.match(body);
@@ -1059,17 +1059,6 @@ class ExpensiMark {
1059
1059
  if (parseBodyTag) {
1060
1060
  generatedMarkdown = parseBodyTag[2];
1061
1061
  }
1062
- if (maxBodyLength > 0) {
1063
- /*
1064
- * Some HTML sources (such as Microsoft Word) have headers larger than the typical maxLength of
1065
- * 10K even for a small body text. So the text is truncated after extracting the body element, to
1066
- * maximise the amount of body text that is included while still staying inside the length limit.
1067
- *
1068
- * The truncation happens before HTML to Markdown conversion, as the conversion is very slow for
1069
- * large input especially on mobile devices.
1070
- */
1071
- generatedMarkdown = generatedMarkdown.slice(0, maxBodyLength);
1072
- }
1073
1062
  generatedMarkdown = this.unpackNestedQuotes(generatedMarkdown);
1074
1063
  const processRule = (rule) => {
1075
1064
  // Pre-processes input HTML before applying regex
@@ -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.146",
3
+ "version": "2.0.148",
4
4
  "author": "Expensify, Inc.",
5
5
  "description": "Expensify libraries and components shared across different repos",
6
6
  "homepage": "https://expensify.com",