aotrautils-srv 0.0.542 → 0.0.544

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- /*utils COMMONS library associated with aotra version : «1_29072022-2359 (24/07/2023-22:30:09)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (26/07/2023-11:44:49)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -1843,24 +1843,27 @@ window.nothing=function(nullable, insist=false){
1843
1843
  return false;
1844
1844
  }
1845
1845
 
1846
- window.getOrCreateAttribute=function(parentObject, attributesName, defaultValue={}){
1846
+ window.getOrCreateAttribute=function(parentObject, attributeNameOrAttributesName, defaultValue={}){
1847
1847
  if(nothing(parentObject)) return null;
1848
- if(nothing(attributesName)) return null;
1849
- if(isString(attributesName)){
1850
- const attributeName=attributesName;
1848
+ if(nothing(attributeNameOrAttributesName)) return parentObject;
1849
+ if(isString(attributeNameOrAttributesName) || (isArray(attributeNameOrAttributesName) && attributeNameOrAttributesName.length===1)){
1850
+ const attributeName=(isArray(attributeNameOrAttributesName) && attributeNameOrAttributesName.length===1)?
1851
+ attributeNameOrAttributesName[0]:attributeNameOrAttributesName;
1851
1852
  if(parentObject[attributeName]==null && defaultValue!=null){
1852
1853
  parentObject[attributeName]=defaultValue;
1853
1854
  }
1854
1855
  return parentObject[attributeName];
1855
1856
  }
1856
- if(isArray(attributesName)){
1857
- let item=parentObject;
1858
- foreach(attributesName,(attributeName)=>{
1859
- item=getOrCreateAttribute(item, attributeName, defaultValue);
1860
- });
1857
+ if(isArray(attributeNameOrAttributesName)){
1858
+ // let item=parentObject;
1859
+ // foreach(attributeNameOrAttributesName,(attributeName)=>{
1860
+ // const child=getOrCreateAttribute(item, attributeName, defaultValue);
1861
+ // });
1862
+ const item=getOrCreateAttribute(parentObject, attributeNameOrAttributesName.splice(1), defaultValue);
1863
+
1861
1864
  return item;
1862
1865
  }
1863
- return null;
1866
+ return parentObject;
1864
1867
  }
1865
1868
 
1866
1869
  window.nonull=function(value,defaultValue){
@@ -4950,7 +4953,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4950
4953
 
4951
4954
 
4952
4955
 
4953
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (24/07/2023-22:30:09)»*/
4956
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (26/07/2023-11:44:49)»*/
4954
4957
  /*-----------------------------------------------------------------------------*/
4955
4958
 
4956
4959
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.542",
3
+ "version": "0.0.544",
4
4
  "main": "aotrautils-srv.build.js",
5
5
  "description": "A library for vanilla javascript utils (server-side) used in aotra javascript CMS",
6
6
  "author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",