@domql/utils 2.5.108 → 2.5.113
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/array.js +3 -3
- package/dist/cjs/array.js +2 -2
- package/dist/cjs/object.js +1 -1
- package/dist/cjs/string.js +8 -0
- package/object.js +1 -1
- package/package.json +2 -2
- package/string.js +8 -0
package/array.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { deepCloneWithExtend, deepMerge } from './object'
|
|
4
4
|
import { isArray, isNumber, isString } from './types'
|
|
5
5
|
|
|
6
6
|
export const arrayContainsOtherArray = (arr1, arr2) => {
|
|
@@ -40,14 +40,14 @@ export const joinArrays = (...arrays) => {
|
|
|
40
40
|
* Merges array extendtypes
|
|
41
41
|
*/
|
|
42
42
|
export const mergeArray = (arr, excludeFrom = []) => {
|
|
43
|
-
return arr.reduce((a, c) => deepMerge(a,
|
|
43
|
+
return arr.reduce((a, c) => deepMerge(a, deepCloneWithExtend(c, excludeFrom), excludeFrom), {})
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Merges array extends
|
|
48
48
|
*/
|
|
49
49
|
export const mergeAndCloneIfArray = obj => {
|
|
50
|
-
return isArray(obj) ? mergeArray(obj) :
|
|
50
|
+
return isArray(obj) ? mergeArray(obj) : deepCloneWithExtend(obj)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export const cutArrayBeforeValue = (arr, value) => {
|
package/dist/cjs/array.js
CHANGED
|
@@ -67,10 +67,10 @@ const joinArrays = (...arrays) => {
|
|
|
67
67
|
return [].concat(...arrays);
|
|
68
68
|
};
|
|
69
69
|
const mergeArray = (arr, excludeFrom = []) => {
|
|
70
|
-
return arr.reduce((a, c) => (0, import_object.deepMerge)(a, (0, import_object.
|
|
70
|
+
return arr.reduce((a, c) => (0, import_object.deepMerge)(a, (0, import_object.deepCloneWithExtend)(c, excludeFrom), excludeFrom), {});
|
|
71
71
|
};
|
|
72
72
|
const mergeAndCloneIfArray = (obj) => {
|
|
73
|
-
return (0, import_types.isArray)(obj) ? mergeArray(obj) : (0, import_object.
|
|
73
|
+
return (0, import_types.isArray)(obj) ? mergeArray(obj) : (0, import_object.deepCloneWithExtend)(obj);
|
|
74
74
|
};
|
|
75
75
|
const cutArrayBeforeValue = (arr, value) => {
|
|
76
76
|
const index = arr.indexOf(value);
|
package/dist/cjs/object.js
CHANGED
|
@@ -413,7 +413,7 @@ const overwriteShallow = (obj, params, excludeFrom = []) => {
|
|
|
413
413
|
};
|
|
414
414
|
const overwriteDeep = (obj, params, excludeFrom = []) => {
|
|
415
415
|
for (const e in params) {
|
|
416
|
-
if (e === "
|
|
416
|
+
if (e === "__ref")
|
|
417
417
|
continue;
|
|
418
418
|
if (excludeFrom.includes(e) || e.startsWith("__"))
|
|
419
419
|
continue;
|
package/dist/cjs/string.js
CHANGED
|
@@ -20,6 +20,8 @@ var string_exports = {};
|
|
|
20
20
|
__export(string_exports, {
|
|
21
21
|
customDecodeURIComponent: () => customDecodeURIComponent,
|
|
22
22
|
customEncodeURIComponent: () => customEncodeURIComponent,
|
|
23
|
+
decodeNewlines: () => decodeNewlines,
|
|
24
|
+
encodeNewlines: () => encodeNewlines,
|
|
23
25
|
findKeyPosition: () => findKeyPosition,
|
|
24
26
|
lowercaseFirstLetter: () => lowercaseFirstLetter,
|
|
25
27
|
replaceLiteralsWithObjectFields: () => replaceLiteralsWithObjectFields,
|
|
@@ -123,6 +125,12 @@ const replaceOctalEscapeSequences = (str) => {
|
|
|
123
125
|
return char;
|
|
124
126
|
});
|
|
125
127
|
};
|
|
128
|
+
const encodeNewlines = (str) => {
|
|
129
|
+
return str.split("\n").join("/////n").split("`").join("/////tilde").split("$").join("/////dlrsgn");
|
|
130
|
+
};
|
|
131
|
+
const decodeNewlines = (encodedStr) => {
|
|
132
|
+
return encodedStr.split("/////n").join("\n").split("/////tilde").join("`").split("/////dlrsgn").join("$");
|
|
133
|
+
};
|
|
126
134
|
const customEncodeURIComponent = (str) => {
|
|
127
135
|
return str.split("").map((char) => {
|
|
128
136
|
if (/[^a-zA-Z0-9\s]/.test(char)) {
|
package/object.js
CHANGED
|
@@ -428,7 +428,7 @@ export const overwriteShallow = (obj, params, excludeFrom = []) => {
|
|
|
428
428
|
*/
|
|
429
429
|
export const overwriteDeep = (obj, params, excludeFrom = []) => {
|
|
430
430
|
for (const e in params) {
|
|
431
|
-
if (e === '
|
|
431
|
+
if (e === '__ref') continue
|
|
432
432
|
if (excludeFrom.includes(e) || e.startsWith('__')) continue
|
|
433
433
|
const objProp = obj[e]
|
|
434
434
|
const paramsProp = params[e]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.113",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build": "yarn build:cjs",
|
|
24
24
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "8436abbfa2752c4659982516ff9ad1db80862e42",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.12.0"
|
|
29
29
|
}
|
package/string.js
CHANGED
|
@@ -125,6 +125,14 @@ export const replaceOctalEscapeSequences = (str) => {
|
|
|
125
125
|
})
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
export const encodeNewlines = (str) => {
|
|
129
|
+
return str.split('\n').join('/////n').split('`').join('/////tilde').split('$').join('/////dlrsgn')
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const decodeNewlines = (encodedStr) => {
|
|
133
|
+
return encodedStr.split('/////n').join('\n').split('/////tilde').join('`').split('/////dlrsgn').join('$')
|
|
134
|
+
}
|
|
135
|
+
|
|
128
136
|
export const customEncodeURIComponent = (str) => {
|
|
129
137
|
return str.split('').map(char => {
|
|
130
138
|
if (/[^a-zA-Z0-9\s]/.test(char)) {
|