@domql/utils 2.5.85 → 2.5.86

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 CHANGED
@@ -7,6 +7,12 @@ export const arrayContainsOtherArray = (arr1, arr2) => {
7
7
  return arr2.every(val => arr1.includes(val))
8
8
  }
9
9
 
10
+ export const getFrequencyInArray = (arr, value) => {
11
+ return arr.reduce((count, currentValue) => {
12
+ return currentValue === value ? count + 1 : count
13
+ }, 0)
14
+ }
15
+
10
16
  export const removeFromArray = (arr, index) => {
11
17
  if (isString(index)) index = parseInt(index)
12
18
  if (isNumber(index)) {
@@ -88,7 +94,7 @@ export const removeValueFromArray = (arr, value) => {
88
94
  newArray.splice(index, 1)
89
95
  return newArray
90
96
  }
91
- return arr.slice()
97
+ return arr
92
98
  }
93
99
 
94
100
  export const removeValueFromArrayAll = (arr, value) => {
package/dist/cjs/array.js CHANGED
@@ -22,6 +22,7 @@ __export(array_exports, {
22
22
  createNestedObject: () => createNestedObject,
23
23
  cutArrayAfterValue: () => cutArrayAfterValue,
24
24
  cutArrayBeforeValue: () => cutArrayBeforeValue,
25
+ getFrequencyInArray: () => getFrequencyInArray,
25
26
  joinArrays: () => joinArrays,
26
27
  mergeAndCloneIfArray: () => mergeAndCloneIfArray,
27
28
  mergeArray: () => mergeArray,
@@ -36,6 +37,11 @@ var import_types = require("./types");
36
37
  const arrayContainsOtherArray = (arr1, arr2) => {
37
38
  return arr2.every((val) => arr1.includes(val));
38
39
  };
40
+ const getFrequencyInArray = (arr, value) => {
41
+ return arr.reduce((count, currentValue) => {
42
+ return currentValue === value ? count + 1 : count;
43
+ }, 0);
44
+ };
39
45
  const removeFromArray = (arr, index) => {
40
46
  if ((0, import_types.isString)(index))
41
47
  index = parseInt(index);
@@ -102,7 +108,7 @@ const removeValueFromArray = (arr, value) => {
102
108
  newArray.splice(index, 1);
103
109
  return newArray;
104
110
  }
105
- return arr.slice();
111
+ return arr;
106
112
  };
107
113
  const removeValueFromArrayAll = (arr, value) => {
108
114
  return arr.filter((item) => item !== value);
@@ -209,7 +209,10 @@ const objectToString = (obj, indent = 0) => {
209
209
  str += `${spaces} ${objectToString(element, indent + 2)},
210
210
  `;
211
211
  } else if ((0, import_types.isString)(element)) {
212
- str += `${spaces} '${element}',
212
+ if (element.includes("\n"))
213
+ str += spaces + " `" + element + "`,\n";
214
+ else
215
+ str += `${spaces} '${element}',
213
216
  `;
214
217
  } else {
215
218
  str += `${spaces} ${element},
package/object.js CHANGED
@@ -190,7 +190,8 @@ export const objectToString = (obj, indent = 0) => {
190
190
  if (isObject(element) && element !== null) {
191
191
  str += `${spaces} ${objectToString(element, indent + 2)},\n`
192
192
  } else if (isString(element)) {
193
- str += `${spaces} '${element}',\n`
193
+ if (element.includes('\n')) str += spaces + ' ' + '`' + element + '`,\n'
194
+ else str += `${spaces} '${element}',\n`
194
195
  } else {
195
196
  str += `${spaces} ${element},\n`
196
197
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.5.85",
3
+ "version": "2.5.86",
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": "d74dca288e3860155be0340404d95a4c872c66aa",
26
+ "gitHead": "6a593e77a9cdf6889175bf674ef60f90385b58df",
27
27
  "devDependencies": {
28
28
  "@babel/core": "^7.12.0"
29
29
  }