@ezez/utils 1.8.0 → 1.9.0
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/CHANGELOG.md +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/removeCommonProperties.d.ts +4 -0
- package/dist/removeCommonProperties.d.ts.map +1 -0
- package/dist/removeCommonProperties.js +15 -0
- package/dist/removeCommonProperties.js.map +1 -0
- package/dist/replace.d.ts.map +1 -1
- package/dist/replace.js +5 -1
- package/dist/replace.js.map +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/functions/cap.html +6 -5
- package/docs/functions/capitalize.html +6 -5
- package/docs/functions/coalesce.html +6 -5
- package/docs/functions/compareArrays.html +6 -5
- package/docs/functions/compareProps.html +6 -5
- package/docs/functions/ensureArray.html +6 -5
- package/docs/functions/ensureDate.html +6 -5
- package/docs/functions/ensureError.html +6 -5
- package/docs/functions/ensurePrefix.html +6 -5
- package/docs/functions/ensureSuffix.html +6 -5
- package/docs/functions/ensureTimestamp.html +6 -5
- package/docs/functions/escapeRegExp.html +6 -5
- package/docs/functions/formatDate.html +6 -5
- package/docs/functions/get.html +6 -5
- package/docs/functions/getMultiple.html +6 -5
- package/docs/functions/insertSeparator.html +6 -5
- package/docs/functions/isEmpty.html +6 -5
- package/docs/functions/isNumericString.html +6 -5
- package/docs/functions/isPlainObject.html +6 -5
- package/docs/functions/last.html +6 -5
- package/docs/functions/later-1.html +6 -5
- package/docs/functions/mapAsync.html +6 -5
- package/docs/functions/mapValues.html +6 -5
- package/docs/functions/match.html +6 -5
- package/docs/functions/merge.html +14 -13
- package/docs/functions/mostFrequent.html +6 -5
- package/docs/functions/noop.html +6 -5
- package/docs/functions/occurrences.html +6 -5
- package/docs/functions/omit.html +6 -5
- package/docs/functions/pick.html +6 -5
- package/docs/functions/pull.html +6 -5
- package/docs/functions/remove.html +6 -5
- package/docs/functions/removeCommonProperties.html +151 -0
- package/docs/functions/replace.html +6 -5
- package/docs/functions/rethrow.html +6 -5
- package/docs/functions/safe.html +7 -6
- package/docs/functions/scale.html +6 -5
- package/docs/functions/seq.html +6 -5
- package/docs/functions/seqEarlyBreak.html +6 -5
- package/docs/functions/set.html +6 -5
- package/docs/functions/setImmutable.html +6 -5
- package/docs/functions/sortBy.html +6 -5
- package/docs/functions/sortProps.html +6 -5
- package/docs/functions/stripPrefix.html +6 -5
- package/docs/functions/stripSuffix.html +6 -5
- package/docs/functions/throttle.html +6 -5
- package/docs/functions/truthy.html +6 -5
- package/docs/functions/unique.html +6 -5
- package/docs/functions/wait.html +6 -5
- package/docs/functions/waitFor.html +6 -5
- package/docs/functions/waitSync.html +6 -5
- package/docs/index.html +5 -4
- package/docs/interfaces/ComparePropsOptions.html +6 -6
- package/docs/interfaces/GetMultipleSource.html +6 -5
- package/docs/interfaces/GetSource.html +6 -5
- package/docs/interfaces/IsNumericStringOptions.html +9 -9
- package/docs/interfaces/OccurencesOptions.html +6 -6
- package/docs/interfaces/SetImmutableSource.html +6 -5
- package/docs/interfaces/SetSource.html +6 -5
- package/docs/interfaces/ThrottleOptions.html +7 -7
- package/docs/interfaces/ThrottledFunctionExtras.html +7 -7
- package/docs/modules.html +6 -4
- package/docs/pages/CHANGELOG.html +72 -49
- package/docs/pages/Introduction.html +5 -4
- package/docs/types/Later.html +6 -5
- package/docs/types/MapValuesFn.html +6 -5
- package/docs/types/MatchCallback.html +6 -5
- package/docs/types/SeqEarlyBreaker.html +6 -5
- package/docs/types/SeqFn.html +6 -5
- package/docs/types/SeqFunctions.html +6 -5
- package/docs/types/SetImmutablePath.html +6 -5
- package/docs/types/ThrottledFunction.html +6 -5
- package/docs/variables/mapValuesUNSET.html +6 -5
- package/docs/variables/mergeUNSET.html +6 -5
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/removeCommonProperties.d.ts +4 -0
- package/esm/removeCommonProperties.d.ts.map +1 -0
- package/esm/removeCommonProperties.js +12 -0
- package/esm/removeCommonProperties.js.map +1 -0
- package/esm/replace.d.ts.map +1 -1
- package/esm/replace.js +5 -1
- package/esm/replace.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +1 -0
- package/src/removeCommonProperties.spec.ts +34 -0
- package/src/removeCommonProperties.ts +39 -0
- package/src/replace.spec.ts +4 -0
- package/src/replace.ts +5 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>mergeUNSET | @ezez/utils - v1.
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>mergeUNSET | @ezez/utils - v1.9.0</title><meta name="description" content="Documentation for @ezez/utils - v1.9.0"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script><link rel="stylesheet" href="../assets/pages.css"/></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
|
|
2
2
|
<div class="tsd-toolbar-contents container">
|
|
3
3
|
<div class="table-cell" id="tsd-search" data-base="..">
|
|
4
4
|
<div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
<div id="tsd-toolbar-links"></div></div>
|
|
7
7
|
<ul class="results">
|
|
8
8
|
<li class="state loading">Preparing search index...</li>
|
|
9
|
-
<li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@ezez/utils - v1.
|
|
9
|
+
<li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@ezez/utils - v1.9.0</a></div>
|
|
10
10
|
<div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
|
|
11
11
|
<div class="container container-main">
|
|
12
12
|
<div class="col-8 col-content">
|
|
13
13
|
<div class="tsd-page-title">
|
|
14
14
|
<ul class="tsd-breadcrumb">
|
|
15
|
-
<li><a href="../modules.html">@ezez/utils - v1.
|
|
15
|
+
<li><a href="../modules.html">@ezez/utils - v1.9.0</a></li>
|
|
16
16
|
<li><a href="mergeUNSET.html">mergeUNSET</a></li></ul>
|
|
17
17
|
<h1>Variable mergeUNSET<code class="tsd-tag ts-flagConst">Const</code> </h1></div>
|
|
18
18
|
<div class="tsd-signature">mergeUNSET<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{}</span><span class="tsd-signature-symbol"> = ...</span></div>
|
|
@@ -25,7 +25,7 @@ If this value is merged with previous value - the property in a final object wil
|
|
|
25
25
|
<h4>Type declaration</h4>
|
|
26
26
|
<ul class="tsd-parameters"></ul></div><aside class="tsd-sources">
|
|
27
27
|
<ul>
|
|
28
|
-
<li>Defined in <a href="https://github.com/dzek69/bottom-line/blob/
|
|
28
|
+
<li>Defined in <a href="https://github.com/dzek69/bottom-line/blob/229736d/src/merge.ts#L6">merge.ts:6</a></li></ul></aside></div>
|
|
29
29
|
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
|
|
30
30
|
<div class="tsd-navigation settings">
|
|
31
31
|
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
|
|
@@ -45,7 +45,7 @@ If this value is merged with previous value - the property in a final object wil
|
|
|
45
45
|
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Modules</h3></summary>
|
|
46
46
|
<div class="tsd-accordion-details">
|
|
47
47
|
<ul>
|
|
48
|
-
<li><a href="../modules.html">@ezez/utils -<wbr/> v1.
|
|
48
|
+
<li><a href="../modules.html">@ezez/utils -<wbr/> v1.9.0</a>
|
|
49
49
|
<ul>
|
|
50
50
|
<li class="pages-entry pages-entry-page pages-entry-depth-1"><a href="../pages/Introduction.html">Introduction</a></li>
|
|
51
51
|
<li class="pages-entry pages-entry-page pages-entry-depth-1"><a href="../pages/CHANGELOG.html">Changelog</a></li></ul></li></ul></div></details></nav>
|
|
@@ -102,6 +102,7 @@ If this value is merged with previous value - the property in a final object wil
|
|
|
102
102
|
<li class="tsd-kind-function"><a href="../functions/pick.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>pick</a></li>
|
|
103
103
|
<li class="tsd-kind-function"><a href="../functions/pull.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>pull</a></li>
|
|
104
104
|
<li class="tsd-kind-function"><a href="../functions/remove.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>remove</a></li>
|
|
105
|
+
<li class="tsd-kind-function"><a href="../functions/removeCommonProperties.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>remove<wbr/>Common<wbr/>Properties</a></li>
|
|
105
106
|
<li class="tsd-kind-function"><a href="../functions/replace.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>replace</a></li>
|
|
106
107
|
<li class="tsd-kind-function"><a href="../functions/rethrow.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>rethrow</a></li>
|
|
107
108
|
<li class="tsd-kind-function"><a href="../functions/safe.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>safe</a></li>
|
package/esm/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export * from "./omit.js";
|
|
|
30
30
|
export * from "./pick.js";
|
|
31
31
|
export * from "./pull.js";
|
|
32
32
|
export * from "./remove.js";
|
|
33
|
+
export * from "./removeCommonProperties.js";
|
|
33
34
|
export * from "./replace.js";
|
|
34
35
|
export * from "./rethrow.js";
|
|
35
36
|
export * from "./safe.js";
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","s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B,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -30,6 +30,7 @@ export * from "./omit.js";
|
|
|
30
30
|
export * from "./pick.js";
|
|
31
31
|
export * from "./pull.js";
|
|
32
32
|
export * from "./remove.js";
|
|
33
|
+
export * from "./removeCommonProperties.js";
|
|
33
34
|
export * from "./replace.js";
|
|
34
35
|
export * from "./rethrow.js";
|
|
35
36
|
export * from "./safe.js";
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WA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CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeCommonProperties.d.ts","sourceRoot":"","sources":["../src/removeCommonProperties.ts"],"names":[],"mappings":"AAAA,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAwBnC,QAAA,MAAM,sBAAsB,WAAY,GAAG,WAAW,GAAG,cAAc,GAAG,EAAE,SAU3E,CAAC;AAEF,OAAO,EACH,sBAAsB,GACzB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const removeCommonProperties = (source, target1, ...targetN) => {
|
|
2
|
+
const targets = [target1, ...targetN];
|
|
3
|
+
const keys = Object.keys(source);
|
|
4
|
+
for (const key of keys) {
|
|
5
|
+
const allTheSame = targets.every((target) => JSON.stringify(target[key]) === JSON.stringify(source[key]));
|
|
6
|
+
if (allTheSame) {
|
|
7
|
+
targets.forEach((target) => delete target[key]);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export { removeCommonProperties, };
|
|
12
|
+
//# sourceMappingURL=removeCommonProperties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeCommonProperties.js","sourceRoot":"","sources":["../src/removeCommonProperties.ts"],"names":[],"mappings":"AAwBA,MAAM,sBAAsB,GAAG,CAAC,MAAW,EAAE,OAAY,EAAE,GAAG,OAAc,EAAE,EAAE;IAC5E,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;IACtC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACpB,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC1G,IAAI,UAAU,EAAE;YAEZ,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;SACnD;KACJ;AACL,CAAC,CAAC;AAEF,OAAO,EACH,sBAAsB,GACzB,CAAC"}
|
package/esm/replace.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../src/replace.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,OAAO,WAAY,MAAM,cAAc,OAAO,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../src/replace.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,OAAO,WAAY,MAAM,cAAc,OAAO,MAAM,EAAE,MAAM,CAAC,WAQlE,CAAC;AAEF,OAAO,EACH,OAAO,GACV,CAAC"}
|
package/esm/replace.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { escapeRegExp } from "./escapeRegExp.js";
|
|
2
2
|
const replace = (source, replaceMap) => {
|
|
3
|
-
const
|
|
3
|
+
const keys = Object.keys(replaceMap);
|
|
4
|
+
if (keys.length === 0) {
|
|
5
|
+
return source;
|
|
6
|
+
}
|
|
7
|
+
const regex = new RegExp(keys.map(escapeRegExp).join("|"), "g");
|
|
4
8
|
return source.replace(regex, (matched) => replaceMap[matched]);
|
|
5
9
|
};
|
|
6
10
|
export { replace, };
|
package/esm/replace.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace.js","sourceRoot":"","sources":["../src/replace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,UAAkC,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"replace.js","sourceRoot":"","sources":["../src/replace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,UAAkC,EAAE,EAAE;IACnE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACrC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACnB,OAAO,MAAM,CAAC;KACjB;IAED,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAChE,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAE,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF,OAAO,EACH,OAAO,GACV,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ezez/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"repository": "https://github.com/dzek69/bottom-line.git",
|
|
5
5
|
"author": "Jacek Nowacki @dzek69 <git-public@dzek.eu>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"lint": "eslint src --ext .ts,.tsx,.js,.jsx,.mjs",
|
|
16
16
|
"lint:fix": "yarn lint --fix",
|
|
17
17
|
"prepack": "yarn compile",
|
|
18
|
-
"prepublishOnly": "yarn
|
|
18
|
+
"prepublishOnly": "yarn lint && yarn test && yarn docs",
|
|
19
19
|
"start:dev": "nodemon",
|
|
20
20
|
"start:dev:compatibility": "TS_NODE_FILES=true yarn start:dev",
|
|
21
21
|
"prepare": "husky install",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@babel/core": "^7.22.1",
|
|
40
40
|
"@babel/preset-env": "^7.22.4",
|
|
41
41
|
"@babel/preset-typescript": "^7.21.5",
|
|
42
|
-
"@dzek69/eslint-config-base": "^2.
|
|
42
|
+
"@dzek69/eslint-config-base": "^2.5.0",
|
|
43
43
|
"@dzek69/eslint-config-import": "^1.2.0",
|
|
44
44
|
"@dzek69/eslint-config-import-typescript": "^1.0.0",
|
|
45
45
|
"@dzek69/eslint-config-typescript": "^1.1.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@typescript-eslint/eslint-plugin": "^5.58.0",
|
|
50
50
|
"@typescript-eslint/parser": "^5.58.0",
|
|
51
51
|
"babel-plugin-module-extension": "^0.1.3",
|
|
52
|
-
"eslint": "^8.
|
|
52
|
+
"eslint": "^8.44.0",
|
|
53
53
|
"eslint-plugin-import": "^2.27.5",
|
|
54
54
|
"fs-extra": "^11.1.1",
|
|
55
55
|
"husky": "^8.0.3",
|
package/src/index.ts
CHANGED
|
@@ -31,6 +31,7 @@ export * from "./omit.js";
|
|
|
31
31
|
export * from "./pick.js";
|
|
32
32
|
export * from "./pull.js";
|
|
33
33
|
export * from "./remove.js";
|
|
34
|
+
export * from "./removeCommonProperties.js";
|
|
34
35
|
export * from "./replace.js";
|
|
35
36
|
export * from "./rethrow.js";
|
|
36
37
|
export * from "./safe.js";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { removeCommonProperties } from "./removeCommonProperties.js";
|
|
2
|
+
|
|
3
|
+
describe("removeCommonProperties", () => {
|
|
4
|
+
it("removes common properties in two objects", async () => {
|
|
5
|
+
const src = { a: 1, b: 2, c: 3 };
|
|
6
|
+
const target = { a: 1, b: 2, c: 3, d: 4 };
|
|
7
|
+
removeCommonProperties(src, target);
|
|
8
|
+
|
|
9
|
+
must(target).eql({ d: 4 });
|
|
10
|
+
must(src).eql({ a: 1, b: 2, c: 3 });
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("removes common properties in three objects", async () => {
|
|
14
|
+
const src = { a: 1, b: 2, c: 3 };
|
|
15
|
+
const target1 = { a: 1, b: 2, c: 3, d: 4 };
|
|
16
|
+
const target2 = { a: 1, b: 2, c: 9, d: 4 };
|
|
17
|
+
|
|
18
|
+
removeCommonProperties(src, target1, target2);
|
|
19
|
+
|
|
20
|
+
must(target1).eql({ c: 3, d: 4 });
|
|
21
|
+
must(target2).eql({ c: 9, d: 4 });
|
|
22
|
+
must(src).eql({ a: 1, b: 2, c: 3 });
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("removes common properties in two objects, even if they are nested", async () => {
|
|
26
|
+
const src = { a: 1, b: 2, c: { d: 3 } };
|
|
27
|
+
const target1 = { a: 1, b: 2, c: { d: 3 }, e: 4 };
|
|
28
|
+
|
|
29
|
+
removeCommonProperties(src, target1);
|
|
30
|
+
|
|
31
|
+
must(target1).eql({ e: 4 });
|
|
32
|
+
must(src).eql({ a: 1, b: 2, c: { d: 3 } });
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
type Obj = Record<string, unknown>;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Removes properties from all targets if they are the same as in source. It mutates the targets!
|
|
5
|
+
* Values are JSON-serialized before comparison, therefore, it will consider arrays and objects with the same content
|
|
6
|
+
* as equal.
|
|
7
|
+
*
|
|
8
|
+
* The property must be exactly the same in all targets. If even one target has different value for given property - the
|
|
9
|
+
* property will stay untouched on all targets.
|
|
10
|
+
*
|
|
11
|
+
* If you want to remove properties from each target that has given property the same as source - just run this
|
|
12
|
+
* function in a loop, giving one target at a time.
|
|
13
|
+
*
|
|
14
|
+
* Note: This function is intended to be used on small data sets that are JSON serializable. It will crash on circular
|
|
15
|
+
* references and may produce unexpected results on non-serializable data (like functions).
|
|
16
|
+
*
|
|
17
|
+
* @param source - source object
|
|
18
|
+
* @param target1 - first target object (required)
|
|
19
|
+
* @param ...targetN - more target objects (optional)
|
|
20
|
+
* @example removeCommonProperties({ title: "Hello", author: "John"}, { title: "Hello 2", author: "John" }, { title: "Hello 3", author: "John" });
|
|
21
|
+
* // targets: { title: "Hello 2" }, { title: "Hello 3" }
|
|
22
|
+
* @example removeCommonProperties({ title: "Hello", author: "John"}, { title: "Hello 2", author: "John" }, { title: "Hello 3", author: "Matt" });
|
|
23
|
+
* // targets: { title: "Hello 2", author: "John" }, { title: "Hello 3", author: "Matt" }
|
|
24
|
+
*/
|
|
25
|
+
const removeCommonProperties = (source: Obj, target1: Obj, ...targetN: Obj[]) => {
|
|
26
|
+
const targets = [target1, ...targetN];
|
|
27
|
+
const keys = Object.keys(source);
|
|
28
|
+
for (const key of keys) {
|
|
29
|
+
const allTheSame = targets.every((target) => JSON.stringify(target[key]) === JSON.stringify(source[key]));
|
|
30
|
+
if (allTheSame) {
|
|
31
|
+
// eslint-disable-next-line no-param-reassign,@typescript-eslint/no-dynamic-delete
|
|
32
|
+
targets.forEach((target) => delete target[key]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
removeCommonProperties,
|
|
39
|
+
};
|
package/src/replace.spec.ts
CHANGED
|
@@ -19,4 +19,8 @@ describe("replace", () => {
|
|
|
19
19
|
it("doesn't break on regexp characters", () => {
|
|
20
20
|
replace("Hello.", { ".": "!" }).must.equal("Hello!");
|
|
21
21
|
});
|
|
22
|
+
|
|
23
|
+
it("replaces nothing when empty object given", async () => {
|
|
24
|
+
replace("Hello.", {}).must.equal("Hello.");
|
|
25
|
+
});
|
|
22
26
|
});
|
package/src/replace.ts
CHANGED
|
@@ -9,8 +9,12 @@ import { escapeRegExp } from "./escapeRegExp.js";
|
|
|
9
9
|
* @example replace("Hello, %name%! Nice to meet you %name%!", { "%name%": "Jane" }) // "Hello, Jane! Nice to meet you Jane!"
|
|
10
10
|
*/
|
|
11
11
|
const replace = (source: string, replaceMap: Record<string, string>) => {
|
|
12
|
+
const keys = Object.keys(replaceMap);
|
|
13
|
+
if (keys.length === 0) {
|
|
14
|
+
return source;
|
|
15
|
+
}
|
|
12
16
|
/* eslint-enable max-len */
|
|
13
|
-
const regex = new RegExp(
|
|
17
|
+
const regex = new RegExp(keys.map(escapeRegExp).join("|"), "g");
|
|
14
18
|
return source.replace(regex, (matched) => replaceMap[matched]!);
|
|
15
19
|
};
|
|
16
20
|
|