some-common-functions-js 1.1.5 → 1.1.6

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
@@ -56,3 +56,6 @@ Added the outstanding change log for the previous version.
56
56
  ## Version 1.1.5 - 2025/12/28 - ITA
57
57
  - Improved the documentation of functions to show better on the tooltip in IDEs.
58
58
  - Improved the deepClone function to handle Date and array types that may have dates types better.
59
+
60
+ ## Version 1.1.6 - 2025/12//29 - ITA
61
+ Removed unnecessary use of the getPaths() function in the get() function to improve effieciency.
package/index.js CHANGED
@@ -12,6 +12,7 @@
12
12
  * Improved deepClone() function to handle Date objects and arrays.
13
13
  * Updated get() function to return undefined or supplied default value for paths that do not exist.
14
14
  * Updated test.js file accordingly.
15
+ * 2025/12//29 ITA 1.06 Removed unnecessary use of the getPaths() function in the get() function to improve effieciency.
15
16
  */
16
17
 
17
18
  /**Return true if userName is valid
@@ -287,11 +288,11 @@ module.exports.getSortedObject = getSortedObject;
287
288
  * @returns {*} the value of the field specified by the path, otherwise a default value if supplied.
288
289
  */
289
290
  function get(anObject, path, defaultVal = undefined) {
290
- if (getPaths(anObject).includes(path) === false) {
291
- return defaultVal;
292
- }
293
291
  let paths = path.split('.');
294
292
  let value = anObject[paths[0]];
293
+ if (value === undefined) {
294
+ return defaultVal;
295
+ }
295
296
  if (paths.length > 1) {
296
297
  paths.splice(0, 1);
297
298
  return get(value, paths.join('.'));
@@ -328,8 +329,10 @@ module.exports.set = set;
328
329
  */
329
330
  function unset(anObject, path) {
330
331
  let paths = path.split('.');
332
+ const subObject = anObject[paths[0]];
333
+ if (subObject === undefined)
334
+ return; // field not found.
331
335
  if (paths.length > 1) {
332
- const subObject = anObject[paths[0]];
333
336
  paths.splice(0, 1);
334
337
  unset(subObject, paths.join('.'));
335
338
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "some-common-functions-js",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Common functions used with Javascript objects, and field validation functions.",
5
5
  "keywords": [
6
6
  "validation",