aotrautils 0.0.1015 → 0.0.1017
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.
- aotrautils/aotrautils.build.js +106 -106
- aotrautils/package.json +1 -1
aotrautils/aotrautils.build.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
|
3
|
-
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (20/06/2024-
|
3
|
+
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (20/06/2024-21:39:11)»*/
|
4
4
|
/*-----------------------------------------------------------------------------*/
|
5
5
|
|
6
6
|
|
@@ -3980,111 +3980,111 @@ window.clone=function(obj){
|
|
3980
3980
|
// KNOWN LIMITATIONS : - Only deep-copies ARRAY-TYPE ONLY attributes up to max 99 dimentions !
|
3981
3981
|
// - Not a real deep-copy
|
3982
3982
|
//****************************************************************************************//
|
3983
|
-
|
3984
|
-
|
3985
|
-
window.cloneObjectShallow=function(obj, stateOnly=false, className=null, primitiveAttributesOnly=false
|
3986
|
-
// If you have an array of more than 99 dimensions, then you have quite a serious problem (and in your code, too).
|
3987
|
-
,maxDeepness=99){
|
3988
|
-
|
3989
|
-
var newObj=null;
|
3990
|
-
|
3991
|
-
if(primitiveAttributesOnly){
|
3992
|
-
|
3993
|
-
// We try to set the right class :
|
3994
|
-
newObj=instanciate(className);
|
3995
|
-
|
3996
|
-
// Primitive attributes means never objects, array or function attributes, as the name smartly suggests :
|
3997
|
-
foreach(obj,(attr,attrName)=>{
|
3998
|
-
|
3999
|
-
newObj[attrName]=attr;
|
4000
|
-
},(attr)=>{ return isPrimitive(attr); });
|
4001
|
-
|
4002
|
-
return newObj;
|
4003
|
-
}
|
4004
|
-
|
4005
|
-
|
4006
|
-
// // Case only attributes :
|
4007
|
-
// if(stateOnly){
|
4008
|
-
|
4009
|
-
// We try to set the right class :
|
4010
|
-
newObj=instanciate(className);
|
4011
|
-
|
4012
|
-
|
4013
|
-
foreach(obj,(attr,attrName)=>{
|
4014
|
-
if(attr==null){
|
4015
|
-
newObj[attrName]=null;
|
4016
|
-
}else{
|
4017
|
-
|
4018
|
-
if(isArray(attr)){
|
4019
|
-
|
4020
|
-
newObj[attrName]=[];
|
4021
|
-
|
4022
|
-
foreach(attr,(item,i)=>{
|
4023
|
-
|
4024
|
-
if(isArray(item)){
|
4025
|
-
|
4026
|
-
if(0<maxDeepness){
|
4027
|
-
let newItem=cloneObjectShallow(item, stateOnly, getClassName(item), primitiveAttributesOnly, maxDeepness-1);
|
4028
|
-
newObj[attrName].push(newItem);
|
4029
|
-
}
|
4030
|
-
|
4031
|
-
}else{
|
4032
|
-
newObj[attrName].push(item);
|
4033
|
-
}
|
4034
|
-
|
4035
|
-
},(item)=>{return item==null
|
4036
|
-
// We only copy the primitive objects,
|
4037
|
-
// and the arrays objects :
|
4038
|
-
|| !isObject(item)
|
4039
|
-
|| isArray(item);
|
4040
|
-
} );
|
4041
|
-
|
4042
|
-
}else if(isObject(attr)){
|
4043
|
-
|
4044
|
-
// THIS IS NOT A DEEP COPY !!:
|
4045
|
-
newObj[attrName]=Object.assign({},attr);
|
4046
|
-
|
4047
|
-
if(stateOnly){
|
4048
|
-
foreach(newObj[attrName],(a,k)=>{
|
4049
|
-
delete newObj[attrName][k];
|
4050
|
-
},(a)=>{ return isFunction(a); });
|
4051
|
-
|
4052
|
-
}
|
4053
|
-
|
4054
|
-
}else if((isFunction(attr) && !stateOnly) || isPrimitive(attr)){ // If we have state only and we have a function, we DO NOT copy it :
|
4055
|
-
|
4056
|
-
newObj[attrName]=attr;
|
4057
|
-
|
4058
|
-
}
|
4059
|
-
|
4060
|
-
}
|
4061
|
-
// (CAUTION : not a real deep-copy)
|
4062
|
-
});
|
4063
|
-
|
4064
|
-
return newObj;
|
3983
|
+
// OLD AND BOGUS (SERIOUSLY, DON'T USE IT ANYMORE !) :
|
3984
|
+
//// DEPRECATED use structuredClone(...) instead :
|
3985
|
+
//window.cloneObjectShallow=function(obj, stateOnly=false, className=null, primitiveAttributesOnly=false
|
3986
|
+
// // If you have an array of more than 99 dimensions, then you have quite a serious problem (and in your code, too).
|
3987
|
+
// ,maxDeepness=99){
|
3988
|
+
//
|
3989
|
+
// var newObj=null;
|
3990
|
+
//
|
3991
|
+
// if(primitiveAttributesOnly){
|
3992
|
+
//
|
3993
|
+
// // We try to set the right class :
|
3994
|
+
// newObj=instanciate(className);
|
3995
|
+
//
|
3996
|
+
// // Primitive attributes means never objects, array or function attributes, as the name smartly suggests :
|
3997
|
+
// foreach(obj,(attr,attrName)=>{
|
3998
|
+
//
|
3999
|
+
// newObj[attrName]=attr;
|
4000
|
+
// },(attr)=>{ return isPrimitive(attr); });
|
4001
|
+
//
|
4002
|
+
// return newObj;
|
4065
4003
|
// }
|
4066
|
-
|
4067
|
-
// // Case attributes + functions :
|
4068
4004
|
//
|
4005
|
+
//
|
4006
|
+
//// // Case only attributes :
|
4007
|
+
//// if(stateOnly){
|
4008
|
+
//
|
4069
4009
|
// // We try to set the right class :
|
4070
|
-
//
|
4071
|
-
//
|
4072
|
-
//
|
4073
|
-
//
|
4074
|
-
//
|
4075
|
-
//
|
4076
|
-
//
|
4077
|
-
//
|
4078
|
-
//
|
4079
|
-
//
|
4080
|
-
//
|
4081
|
-
// // Will (not-really deeply) copy the functions too :
|
4082
|
-
// newObj=Object.assign({},obj);
|
4083
|
-
// }
|
4010
|
+
// newObj=instanciate(className);
|
4011
|
+
//
|
4012
|
+
//
|
4013
|
+
// foreach(obj,(attr,attrName)=>{
|
4014
|
+
// if(attr==null){
|
4015
|
+
// newObj[attrName]=null;
|
4016
|
+
// }else{
|
4017
|
+
//
|
4018
|
+
// if(isArray(attr)){
|
4019
|
+
//
|
4020
|
+
// newObj[attrName]=[];
|
4084
4021
|
//
|
4022
|
+
// foreach(attr,(item,i)=>{
|
4023
|
+
//
|
4024
|
+
// if(isArray(item)){
|
4025
|
+
//
|
4026
|
+
// if(0<maxDeepness){
|
4027
|
+
// let newItem=cloneObjectShallow(item, stateOnly, getClassName(item), primitiveAttributesOnly, maxDeepness-1);
|
4028
|
+
// newObj[attrName].push(newItem);
|
4029
|
+
// }
|
4030
|
+
//
|
4031
|
+
// }else{
|
4032
|
+
// newObj[attrName].push(item);
|
4033
|
+
// }
|
4034
|
+
//
|
4035
|
+
// },(item)=>{return item==null
|
4036
|
+
// // We only copy the primitive objects,
|
4037
|
+
// // and the arrays objects :
|
4038
|
+
// || !isObject(item)
|
4039
|
+
// || isArray(item);
|
4040
|
+
// } );
|
4041
|
+
//
|
4042
|
+
// }else if(isObject(attr)){
|
4043
|
+
//
|
4044
|
+
// // THIS IS NOT A DEEP COPY !!:
|
4045
|
+
// newObj[attrName]=Object.assign({},attr);
|
4046
|
+
//
|
4047
|
+
// if(stateOnly){
|
4048
|
+
// foreach(newObj[attrName],(a,k)=>{
|
4049
|
+
// delete newObj[attrName][k];
|
4050
|
+
// },(a)=>{ return isFunction(a); });
|
4051
|
+
//
|
4052
|
+
// }
|
4085
4053
|
//
|
4054
|
+
// }else if((isFunction(attr) && !stateOnly) || isPrimitive(attr)){ // If we have state only and we have a function, we DO NOT copy it :
|
4055
|
+
//
|
4056
|
+
// newObj[attrName]=attr;
|
4057
|
+
//
|
4058
|
+
// }
|
4059
|
+
//
|
4060
|
+
// }
|
4061
|
+
// // (CAUTION : not a real deep-copy)
|
4062
|
+
// });
|
4063
|
+
//
|
4086
4064
|
// return newObj;
|
4087
|
-
}
|
4065
|
+
//// }
|
4066
|
+
//
|
4067
|
+
//// // Case attributes + functions :
|
4068
|
+
////
|
4069
|
+
//// // We try to set the right class :
|
4070
|
+
//// if(className){
|
4071
|
+
//// try{
|
4072
|
+
//// // TODO : FIXME : I don't like that at all, to use eval(...), but on today I know of no other solution... :
|
4073
|
+
//// newObj=eval("new "+className+"();");
|
4074
|
+
//// }catch(e){
|
4075
|
+
//// // (CAUTION : not a real deep-copy)
|
4076
|
+
//// // Will (not-really deeply) copy the functions too :
|
4077
|
+
//// newObj=Object.assign({},obj);
|
4078
|
+
//// }
|
4079
|
+
//// }else{
|
4080
|
+
//// // (CAUTION : not deep-copy)
|
4081
|
+
//// // Will (not-really deeply) copy the functions too :
|
4082
|
+
//// newObj=Object.assign({},obj);
|
4083
|
+
//// }
|
4084
|
+
////
|
4085
|
+
////
|
4086
|
+
//// return newObj;
|
4087
|
+
//};
|
4088
4088
|
|
4089
4089
|
|
4090
4090
|
window.isProperAttributeName=function(key){
|
@@ -4669,10 +4669,10 @@ window.getAsFlatStructureImpl=function(rawObject, stateOnly=false
|
|
4669
4669
|
|
4670
4670
|
// The new object is added to the flat map :
|
4671
4671
|
// (We don't care to set the real class here, because this object will have a JSONtype attribute in the end. This new result object will be a pure JSON information.)
|
4672
|
-
let result=cloneObjectShallow(workingOriginalObject, stateOnly, null, true);
|
4672
|
+
// OLD AND BOGUS (SERIOUSLY, DON'T USE IT ANYMORE !) : let result=cloneObjectShallow(workingOriginalObject, stateOnly, null, true);
|
4673
|
+
let result=structuredClone(workingOriginalObject);
|
4673
4674
|
|
4674
4675
|
|
4675
|
-
|
4676
4676
|
// We set the class name to the new result object :
|
4677
4677
|
let className=getClassName(workingOriginalObject);
|
4678
4678
|
if(className!=="Array"){ // No need to indicate that this JSON object is an array, since "[" indicates it by the JSON language definition.
|
@@ -4854,7 +4854,7 @@ window.getAsTreeStructureImpl=function(oldMap, stateOnly=false, removeTypeInfo=t
|
|
4854
4854
|
// console.log("aaaaaaaaaaaaaaa oldObj:",oldObj);
|
4855
4855
|
// }
|
4856
4856
|
|
4857
|
-
// OLD : let newObj=cloneObjectShallow(oldObj, stateOnly, className);
|
4857
|
+
// OLD AND BOGUS (SERIOUSLY, DON'T USE IT ANYMORE !) : let newObj=cloneObjectShallow(oldObj, stateOnly, className);
|
4858
4858
|
let newObj=structuredClone(oldObj);
|
4859
4859
|
|
4860
4860
|
|
@@ -5354,7 +5354,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
|
|
5354
5354
|
|
5355
5355
|
|
5356
5356
|
|
5357
|
-
/*utils CLIENT library associated with aotra version : «1_29072022-2359 (20/06/2024-
|
5357
|
+
/*utils CLIENT library associated with aotra version : «1_29072022-2359 (20/06/2024-21:39:11)»*/
|
5358
5358
|
/*-----------------------------------------------------------------------------*/
|
5359
5359
|
/* ## Utility global methods in a browser (htmljs) client environment.
|
5360
5360
|
*
|
@@ -13565,7 +13565,7 @@ createOritaMicroClient=function(url, port, isNode=false, staticMicroClientIdPara
|
|
13565
13565
|
|
13566
13566
|
|
13567
13567
|
|
13568
|
-
/*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (20/06/2024-
|
13568
|
+
/*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (20/06/2024-21:39:11)»*/
|
13569
13569
|
/*-----------------------------------------------------------------------------*/
|
13570
13570
|
|
13571
13571
|
|
@@ -14804,7 +14804,7 @@ function rayVsUnitSphereClosestPoint(p, r) {
|
|
14804
14804
|
// MUST REMAIN AT THE END OF THIS LIBRARY FILE !
|
14805
14805
|
|
14806
14806
|
AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
|
14807
|
-
/*utils SERVER library associated with aotra version : «1_29072022-2359 (20/06/2024-
|
14807
|
+
/*utils SERVER library associated with aotra version : «1_29072022-2359 (20/06/2024-21:39:11)»*/
|
14808
14808
|
/*-----------------------------------------------------------------------------*/
|
14809
14809
|
|
14810
14810
|
|
aotrautils/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "aotrautils",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.1017",
|
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)",
|