@cocreate/utils 1.14.3 → 1.15.1

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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.15.1](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.15.0...v1.15.1) (2022-12-09)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * getValueFromObject returned false if value could not be found, it will now return undefined ([2ca7c4f](https://github.com/CoCreate-app/CoCreate-utils/commit/2ca7c4f1c893025b9240b796858457a1b33cc47e))
7
+
8
+ # [1.15.0](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.14.3...v1.15.0) (2022-12-08)
9
+
10
+
11
+ ### Features
12
+
13
+ * checkValue function to check if value contains template brackets {{}} ([8432c50](https://github.com/CoCreate-app/CoCreate-utils/commit/8432c50ab48e345dfbcaf025128bed7db1abd539))
14
+
1
15
  ## [1.14.3](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.14.2...v1.14.3) (2022-12-07)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/utils",
3
- "version": "1.14.3",
3
+ "version": "1.15.1",
4
4
  "description": "A simple utils component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "utils",
@@ -61,6 +61,6 @@
61
61
  "webpack-log": "^3.0.1"
62
62
  },
63
63
  "dependencies": {
64
- "@cocreate/docs": "^1.4.13"
64
+ "@cocreate/docs": "^1.4.15"
65
65
  }
66
66
  }
package/src/utils.js CHANGED
@@ -34,6 +34,13 @@
34
34
 
35
35
  const ObjectId = (rnd = r16 => Math.floor(r16).toString(16)) =>
36
36
  rnd(Date.now()/1000) + ' '.repeat(16).replace(/./g, () => rnd(Math.random()*16));
37
+
38
+ function checkValue(value) {
39
+ if (/{{\s*([\w\W]+)\s*}}/g.test(value))
40
+ return false;
41
+ else
42
+ return true
43
+ }
37
44
 
38
45
  function dotNotationToObject(data, obj = {}) {
39
46
  try {
@@ -78,7 +85,7 @@
78
85
  function getValueFromObject(json, path) {
79
86
  try {
80
87
  if (typeof json == 'undefined' || !path)
81
- return false;
88
+ return;
82
89
 
83
90
  if (/\[([0-9]*)\]/g.test(path)) {
84
91
  path = path.replace(/\[/g, '.');
@@ -91,12 +98,12 @@
91
98
 
92
99
  for (let i = 0; i < subpath.length; i++) {
93
100
  jsonData = jsonData[subpath[i]];
94
- if (!jsonData) return false;
101
+ if (!jsonData) return;
95
102
  }
96
103
  return jsonData;
97
104
  }catch(error){
98
105
  console.log("Error in getValueFromObject", error);
99
- return false;
106
+ return;
100
107
  }
101
108
  }
102
109
 
@@ -501,6 +508,7 @@
501
508
 
502
509
  return {
503
510
  ObjectId,
511
+ checkValue,
504
512
  dotNotationToObject,
505
513
  getValueFromObject,
506
514
  domParser,