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.
- package/dist/ExpensiMark.d.ts +1 -1
- package/dist/ExpensiMark.js +1 -12
- package/dist/fastMerge.d.ts +1 -1
- package/dist/fastMerge.js +13 -22
- package/package.json +1 -1
package/dist/ExpensiMark.d.ts
CHANGED
|
@@ -155,7 +155,7 @@ export default class ExpensiMark {
|
|
|
155
155
|
/**
|
|
156
156
|
* Replaces HTML with markdown
|
|
157
157
|
*/
|
|
158
|
-
htmlToMarkdown(htmlString: string, extras?: Extras
|
|
158
|
+
htmlToMarkdown(htmlString: string, extras?: Extras): string;
|
|
159
159
|
/**
|
|
160
160
|
* Convert HTML to text
|
|
161
161
|
*/
|
package/dist/ExpensiMark.js
CHANGED
|
@@ -1051,7 +1051,7 @@ class ExpensiMark {
|
|
|
1051
1051
|
/**
|
|
1052
1052
|
* Replaces HTML with markdown
|
|
1053
1053
|
*/
|
|
1054
|
-
htmlToMarkdown(htmlString, extras = EXTRAS_DEFAULT
|
|
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
|
package/dist/fastMerge.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
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
|
|
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;
|