aotrautils 0.0.602 → 0.0.604

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/09/2023-23:01:17)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (24/09/2023-23:04:49)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -4983,7 +4983,66 @@ JSON.recycle=function recycle($){
4983
4983
 
4984
4984
 
4985
4985
 
4986
+ // JSON parsing management :
4987
+ function parseJSON(strParam){
4988
+
4989
+ if(!isString(strParam)) return strParam;
4990
+
4991
+ if (nothing(strParam))
4992
+ return null;
4993
+ var str=toOneSimplifiedLine(strParam.trim())
4994
+ // OLD : Safer, but necessited to never use «'» in literal strings, and use «´» acute character instead !
4995
+ .replace(/'/gim, "\"");
4996
+ // DOES NOT WORK :
4997
+ // .replace(/,'/gim, ",\"")
4998
+ // .replace(/:'/gim, ":\"")
4999
+ // .replace(/{'/gim, "{\"")
5000
+ // .replace(/}'/gim, "}\"")
5001
+ // .replace(/\['/gim, "[\"")
5002
+ // .replace(/\]'/gim, "]\"");
5003
+ try {
4986
5004
 
5005
+ if((JSON && JSON.parse && typeof JSON.parse !== "undefined" && typeof JSON.parse === "function"
5006
+ ) || jQuery)
5007
+ return JSON.parse(str);
5008
+ if(typeof jQuery !== "undefined" && typeof jQuery.parseJSON !== "undefined" && typeof jQuery.parseJSON === "function"){
5009
+ return jQuery.parseJSON(str);
5010
+ }
5011
+ throw new Error("ERROR : No JSON subsystem found to parse the JSON string.");
5012
+
5013
+ } catch (error){
5014
+ // TRACE
5015
+ log("WARN : Error parsing string «" + strParam + "» as JSON. Trying last-chance fallback.");
5016
+ try {
5017
+ var obj=eval("(" + str + ")");
5018
+
5019
+ return obj;
5020
+ } catch (error2){
5021
+
5022
+ // TRACE
5023
+ log(error2);
5024
+ log("ERROR : Error parsing string «" + strParam + "» as JSON. Last-chance fallback failed." +
5025
+ " CHECK IF THERE IS ANY «'» SINGLE QUOTE CHARACTER IN YOUR LITERALS STRINGS, AND REPLACE IT WITH «´» ACUTE CHARACTER INSTEAD.");
5026
+
5027
+ }
5028
+
5029
+ }
5030
+ return null;
5031
+ }
5032
+
5033
+ function stringifyObject(objectToStringify){
5034
+
5035
+ if(nothing(objectToStringify)) return null;
5036
+
5037
+ if (JSON && JSON.stringify && typeof JSON.stringify !== "undefined" && typeof JSON.stringify === "function"){
5038
+ return JSON.stringify(objectToStringify);
5039
+ }
5040
+ if(typeof jQuery !== "undefined" && typeof jQuery.stringify !== "undefined" && typeof jQuery.stringify === "function"){
5041
+ return jQuery.stringify(objectToStringify);
5042
+ }
5043
+ log("ERROR : No JSON subsystem found to stringify the javascript object.");
5044
+ return null;
5045
+ }
4987
5046
 
4988
5047
 
4989
5048
 
@@ -4995,7 +5054,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4995
5054
 
4996
5055
 
4997
5056
 
4998
- /*utils CLIENT library associated with aotra version : «1_29072022-2359 (24/09/2023-23:01:17)»*/
5057
+ /*utils CLIENT library associated with aotra version : «1_29072022-2359 (24/09/2023-23:04:49)»*/
4999
5058
  /*-----------------------------------------------------------------------------*/
5000
5059
  /* ## Utility global methods in a browser (htmljs) client environment.
5001
5060
  *
@@ -5741,66 +5800,7 @@ function parseXMLString(txt){
5741
5800
  return xmlDoc;
5742
5801
  }
5743
5802
 
5744
- // JSON parsing management :
5745
- function parseJSON(strParam){
5746
-
5747
- if(!isString(strParam)) return strParam;
5748
-
5749
- if (nothing(strParam))
5750
- return null;
5751
- var str=toOneSimplifiedLine(strParam.trim())
5752
- // OLD : Safer, but necessited to never use «'» in literal strings, and use «´» acute character instead !
5753
- .replace(/'/gim, "\"");
5754
- // DOES NOT WORK :
5755
- // .replace(/,'/gim, ",\"")
5756
- // .replace(/:'/gim, ":\"")
5757
- // .replace(/{'/gim, "{\"")
5758
- // .replace(/}'/gim, "}\"")
5759
- // .replace(/\['/gim, "[\"")
5760
- // .replace(/\]'/gim, "]\"");
5761
- try {
5762
5803
 
5763
- if((JSON && JSON.parse && typeof JSON.parse !== "undefined" && typeof JSON.parse === "function"
5764
- ) || jQuery)
5765
- return JSON.parse(str);
5766
- if(typeof jQuery !== "undefined" && typeof jQuery.parseJSON !== "undefined" && typeof jQuery.parseJSON === "function"){
5767
- return jQuery.parseJSON(str);
5768
- }
5769
- throw new Error("ERROR : No JSON subsystem found to parse the JSON string.");
5770
-
5771
- } catch (error){
5772
- // TRACE
5773
- log("WARN : Error parsing string «" + strParam + "» as JSON. Trying last-chance fallback.");
5774
- try {
5775
- var obj=eval("(" + str + ")");
5776
-
5777
- return obj;
5778
- } catch (error2){
5779
-
5780
- // TRACE
5781
- log(error2);
5782
- log("ERROR : Error parsing string «" + strParam + "» as JSON. Last-chance fallback failed." +
5783
- " CHECK IF THERE IS ANY «'» SINGLE QUOTE CHARACTER IN YOUR LITERALS STRINGS, AND REPLACE IT WITH «´» ACUTE CHARACTER INSTEAD.");
5784
-
5785
- }
5786
-
5787
- }
5788
- return null;
5789
- }
5790
-
5791
- function stringifyObject(objectToStringify){
5792
-
5793
- if(nothing(objectToStringify)) return null;
5794
-
5795
- if (JSON && JSON.stringify && typeof JSON.stringify !== "undefined" && typeof JSON.stringify === "function"){
5796
- return JSON.stringify(objectToStringify);
5797
- }
5798
- if(typeof jQuery !== "undefined" && typeof jQuery.stringify !== "undefined" && typeof jQuery.stringify === "function"){
5799
- return jQuery.stringify(objectToStringify);
5800
- }
5801
- log("ERROR : No JSON subsystem found to stringify the javascript object.");
5802
- return null;
5803
- }
5804
5804
 
5805
5805
 
5806
5806
 
@@ -13283,7 +13283,7 @@ createOritaMicroClient=function(url, port, isNode=false, staticMicroClientIdPara
13283
13283
 
13284
13284
 
13285
13285
 
13286
- /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (24/09/2023-23:01:17)»*/
13286
+ /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (24/09/2023-23:04:49)»*/
13287
13287
  /*-----------------------------------------------------------------------------*/
13288
13288
 
13289
13289
 
@@ -14522,7 +14522,7 @@ function rayVsUnitSphereClosestPoint(p, r) {
14522
14522
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
14523
14523
 
14524
14524
  AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
14525
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (24/09/2023-23:01:17)»*/
14525
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (24/09/2023-23:04:49)»*/
14526
14526
  /*-----------------------------------------------------------------------------*/
14527
14527
 
14528
14528
 
aotrautils/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.602",
3
+ "version": "0.0.604",
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)",