aotrautils 0.0.960 → 0.0.962

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 (15/04/2024-03:12:59)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (20/04/2024-05:43:46)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -1678,7 +1678,7 @@ function encodeXORNoPattern(strToEncode,key){
1678
1678
  return result;
1679
1679
  }
1680
1680
 
1681
- function generateRandomString(length,/*NULLABLE*/mode){
1681
+ function generateRandomString(length,/*NULLABLE*/mode=null){
1682
1682
 
1683
1683
  // This list must be very conservative, because we want to be able to pass it through GET URLs !
1684
1684
  // OLD (not enough conservative ?) : const ALLOWED_CHARS="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0912346789_-£¢¤¬²³¼½¾";
@@ -1825,6 +1825,26 @@ function generateRandomString(length,/*NULLABLE*/mode){
1825
1825
  return result;
1826
1826
  }
1827
1827
 
1828
+ function generateRandomStringFromOriginalString(str, randomFactor=1, mode=null){
1829
+ const strLength=str.length;
1830
+ const maxStrLength=strLength*randomFactor;
1831
+ const numberOfCharactersToChange=Math.getRandomInt(maxStrLength);
1832
+ const randomString=generateRandomString(numberOfCharactersToChange, mode);
1833
+ if(strLength<=maxStrLength) return randomString;
1834
+ let strIndexes=[];
1835
+ for(let i=0;i<strLength;i++){
1836
+ strIndexes.push(i);
1837
+ }
1838
+ let chosenIndexes=getRandomsInArray(strIndexes, numberOfCharactersToChange);
1839
+ let newStrAsArray=Array.from(str);
1840
+ // chosenIndexes array size is the same as the number of characters in string randomString :
1841
+ forEach(chosenIndexes,(randomIndex,i)=>{
1842
+ newStrAsArray[randomIndex]=randomString[i];
1843
+ });
1844
+ const newStr=newStrAsArray.join("");
1845
+ return newStr;
1846
+ }
1847
+
1828
1848
 
1829
1849
 
1830
1850
  // NOT AOTESTABLE !
@@ -1976,6 +1996,8 @@ window.foreach=function(arrayOfValues,doOnEachFunction,
1976
1996
  // 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 !
1977
1997
  /*OPTIONAL*/compareFunction=null){
1978
1998
 
1999
+ // TODO : FIXME : Add the possibility to iterate over a string characters ?
2000
+
1979
2001
  if(!arrayOfValues){
1980
2002
  // SILENT ERROR :
1981
2003
  // // TRACE
@@ -5275,7 +5297,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
5275
5297
 
5276
5298
 
5277
5299
 
5278
- /*utils CLIENT library associated with aotra version : «1_29072022-2359 (15/04/2024-03:12:59)»*/
5300
+ /*utils CLIENT library associated with aotra version : «1_29072022-2359 (20/04/2024-05:43:46)»*/
5279
5301
  /*-----------------------------------------------------------------------------*/
5280
5302
  /* ## Utility global methods in a browser (htmljs) client environment.
5281
5303
  *
@@ -13486,7 +13508,7 @@ createOritaMicroClient=function(url, port, isNode=false, staticMicroClientIdPara
13486
13508
 
13487
13509
 
13488
13510
 
13489
- /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (15/04/2024-03:12:59)»*/
13511
+ /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (20/04/2024-05:43:46)»*/
13490
13512
  /*-----------------------------------------------------------------------------*/
13491
13513
 
13492
13514
 
@@ -14725,7 +14747,7 @@ function rayVsUnitSphereClosestPoint(p, r) {
14725
14747
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
14726
14748
 
14727
14749
  AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
14728
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (15/04/2024-03:12:59)»*/
14750
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (20/04/2024-05:43:46)»*/
14729
14751
  /*-----------------------------------------------------------------------------*/
14730
14752
 
14731
14753
 
@@ -16473,7 +16495,7 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
16473
16495
  // CASE BROWSER CONTEXT :
16474
16496
  if(!isNodeContext || typeof(require)=="undefined"){
16475
16497
  // TRACE
16476
- lognow("INFO : We are not running in a nodejs context (isNodeContext:"+isNodeContext+";typeof(require):"+(typeof(require))+"). Using browser library.");
16498
+ lognow("INFO : We are not running in a browser context (isNodeContext:"+isNodeContext+";typeof(require):"+(typeof(require))+"). Using browser library.");
16477
16499
 
16478
16500
  const body=((contains(["POST","PUT"],httpMethod) && requestBodyOrNamedArgs)?JSON.stringify(requestBodyOrNamedArgs):null);
16479
16501
  return new Promise((resolve,reject)=>{
@@ -16515,6 +16537,10 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
16515
16537
 
16516
16538
  // CASE NODEJS CONTEXT :
16517
16539
 
16540
+ // TRACE
16541
+ lognow("INFO : We are running in a nodejs context (isNodeContext:"+isNodeContext+";typeof(require):"+(typeof(require))+"). Using nodejs library.");
16542
+
16543
+
16518
16544
  const isSecure=(!empty(completeURL) && contains(completeURL.toLowerCase(),"https://"));
16519
16545
  const httpHandler=isSecure?require("https"):require("http");
16520
16546
 
@@ -16524,7 +16550,6 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
16524
16550
  method: httpMethod,
16525
16551
  };
16526
16552
 
16527
-
16528
16553
  if(contains(["POST","PUT"],httpMethod)){
16529
16554
  options.json=true;
16530
16555
  }
aotrautils/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.960",
3
+ "version": "0.0.962",
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)",