aotrautils-srv 0.0.541 → 0.0.543

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 (22/07/2023-03:18:17)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (26/07/2023-10:35:03)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -1843,6 +1843,26 @@ window.nothing=function(nullable, insist=false){
1843
1843
  return false;
1844
1844
  }
1845
1845
 
1846
+ window.getOrCreateAttribute=function(parentObject, attributesName, defaultValue={}){
1847
+ if(nothing(parentObject)) return null;
1848
+ if(nothing(attributesName)) return null;
1849
+ if(isString(attributesName)){
1850
+ const attributeName=attributesName;
1851
+ if(parentObject[attributeName]==null && defaultValue!=null){
1852
+ parentObject[attributeName]=defaultValue;
1853
+ }
1854
+ return parentObject[attributeName];
1855
+ }
1856
+ if(isArray(attributesName)){
1857
+ let item=parentObject;
1858
+ foreach(attributesName,(attributeName)=>{
1859
+ item=getOrCreateAttribute(item, attributeName, defaultValue);
1860
+ });
1861
+ return item;
1862
+ }
1863
+ return null;
1864
+ }
1865
+
1846
1866
  window.nonull=function(value,defaultValue){
1847
1867
  if(value===false) return value;
1848
1868
  if(nothing(value)) return defaultValue;
@@ -4930,7 +4950,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4930
4950
 
4931
4951
 
4932
4952
 
4933
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (22/07/2023-03:18:17)»*/
4953
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (26/07/2023-10:35:03)»*/
4934
4954
  /*-----------------------------------------------------------------------------*/
4935
4955
 
4936
4956
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.541",
3
+ "version": "0.0.543",
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)",