aotrautils 0.0.1213 → 0.0.1215

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 (31/03/2025-00:03:44)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (31/03/2025-00:59:21)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -2036,7 +2036,11 @@ window.foreach=function(arrayOfValues,doOnEachFunction,
2036
2036
  // -1: if(a<b)
2037
2037
  // 1: if(a>b)
2038
2038
  // for instance this is a valid javascript compare function : function(a, b){return a-b} so (100,20) returns positive result and (20,100) returns negative result !
2039
- /*OPTIONAL*/compareFunction=null, sortKeys=false){
2039
+ /*OPTIONAL*/compareFunction=null // CAUTION : THIS FUNCTION WILL BE DIFFERENT FOR PLAIN ARRAYS AN FOR ASSOCIATIVE ARRAYS !
2040
+ // FOR PLAIN ARRAYS IT WILL BE DECLARED LIKE THAT (item1,item2)=> return <calculus>
2041
+ // FOR ASSOCIATIVE ARRAYS IT WILL BE DECLARED LIKE THAT (pseudoItem1,pseudoItem2)=> return <calculus>
2042
+ // WHERE pseudoItem IS AN OBJECT AS : {key:<item key in associative array>, value:item} !!!
2043
+ , sortKeys=false){
2040
2044
 
2041
2045
  // TODO : FIXME : Add the possibility to iterate over a string characters ?
2042
2046
 
@@ -2102,7 +2106,7 @@ window.foreach=function(arrayOfValues,doOnEachFunction,
2102
2106
  // return null;
2103
2107
  // }
2104
2108
 
2105
- // TODO : FIXME : Actually this is quite ineffective :
2109
+ // TODO : FIXME : ACTUALLY THIS IS QUITE INEFFICIENT :
2106
2110
  // We completely loop through the associative array three times !
2107
2111
  var sortedKeysAndValues=[];
2108
2112
  for(var key in associativeArray){
@@ -4379,15 +4383,26 @@ window.calculateProtoDelta=function(obj1,obj2,
4379
4383
 
4380
4384
  if(isArray(obj)){
4381
4385
 
4382
- result+="[";
4386
+ const arraySignatures=[];
4383
4387
  foreach(obj,(item)=>{
4384
- result+=getSignatureOnNonCycledObject(item,isHashed,attributesNamesToIgnore)+",";
4388
+ const itemSignature=getSignatureOnNonCycledObject(item,isHashed,attributesNamesToIgnore)+",";
4389
+ // result+=itemSignature;
4390
+ arraySignatures.push(itemSignature);
4385
4391
  });
4392
+
4393
+ result+="[";
4394
+ // We must sort the array items again to be sure the comparison is order-insensitive !
4395
+ foreach(arraySignatures,signature=>{
4396
+ result+=signature+",";
4397
+ },()=>true, (item1,item2)=>item1.localeCompare(item2));
4398
+
4399
+
4386
4400
  result+="]";
4387
4401
 
4388
4402
  }else{
4389
4403
 
4390
- foreach(Object.keys(obj),(key)=>{
4404
+ const objectKeysArray=Object.keys(obj);
4405
+ foreach(objectKeysArray,(key)=>{
4391
4406
 
4392
4407
  let attr=obj[key];
4393
4408
 
@@ -4397,20 +4412,31 @@ window.calculateProtoDelta=function(obj1,obj2,
4397
4412
  result+=key+":";
4398
4413
  if(isArray(attr)){
4399
4414
 
4400
- result+="[";
4401
4415
 
4416
+
4417
+ const arraySignatures=[];
4402
4418
  foreach(attr,(item)=>{
4403
4419
 
4404
4420
  if(isPrimitive(item)){
4405
- result+=item;
4421
+ // result+=item;
4422
+ arraySignatures.push(item);
4406
4423
  }else{
4407
4424
  // OLD : result+=(item==null?"null":(typeof(item)));
4408
4425
  // CAUTION : will cause an INFINITE LOOP if the object contains a CYCLE !
4409
- result+=(item==null?"null":(getSignatureOnNonCycledObject(item,isHashed,attributesNamesToIgnore)));
4426
+ const itemSignature=(item==null?"null":(getSignatureOnNonCycledObject(item,isHashed,attributesNamesToIgnore)));
4427
+ // result+=itemSignature;
4428
+ arraySignatures.push(itemSignature);
4410
4429
  }
4411
- result+=",";
4430
+ //result+=",";
4412
4431
 
4413
4432
  });
4433
+
4434
+ result+="[";
4435
+ // We must sort the array items again to be sure the comparison is order-insensitive !
4436
+ foreach(arraySignatures,signature=>{
4437
+ result+=signature+",";
4438
+ },()=>true, (item1,item2)=>item1.localeCompare(item2));
4439
+
4414
4440
 
4415
4441
  result+="],";
4416
4442
 
@@ -4868,7 +4894,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4868
4894
 
4869
4895
 
4870
4896
 
4871
- /*utils CLIENT library associated with aotra version : «1_29072022-2359 (31/03/2025-00:03:44)»*/
4897
+ /*utils CLIENT library associated with aotra version : «1_29072022-2359 (31/03/2025-00:59:21)»*/
4872
4898
  /*-----------------------------------------------------------------------------*/
4873
4899
  /* ## Utility global methods in a browser (htmljs) client environment.
4874
4900
  *
@@ -13440,7 +13466,7 @@ getAORTACClient=function(clientId=getUUID(), serverNodeOrigin="ws://127.0.0.1:40
13440
13466
 
13441
13467
 
13442
13468
 
13443
- /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (31/03/2025-00:03:44)»*/
13469
+ /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (31/03/2025-00:59:21)»*/
13444
13470
  /*-----------------------------------------------------------------------------*/
13445
13471
 
13446
13472
 
@@ -14679,7 +14705,7 @@ function rayVsUnitSphereClosestPoint(p, r) {
14679
14705
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
14680
14706
 
14681
14707
  AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
14682
- /*utils AI library associated with aotra version : «1_29072022-2359 (31/03/2025-00:03:44)»*/
14708
+ /*utils AI library associated with aotra version : «1_29072022-2359 (31/03/2025-00:59:21)»*/
14683
14709
  /*-----------------------------------------------------------------------------*/
14684
14710
 
14685
14711
 
@@ -14823,7 +14849,7 @@ getOpenAIAPIClient=(modelName, apiURL, agentRole, defaultPrompt)=>{
14823
14849
 
14824
14850
 
14825
14851
 
14826
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (31/03/2025-00:03:44)»*/
14852
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (31/03/2025-00:59:21)»*/
14827
14853
  /*-----------------------------------------------------------------------------*/
14828
14854
 
14829
14855
 
aotrautils/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.1213",
3
+ "version": "0.0.1215",
4
4
  "main": "aotrautils.build.js",
5
5
  "description": "A library for vanilla javascript utils (client-side) used in aotra javascript CMS",
6
6
  "author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",