aotrautils-srv 0.0.802 → 0.0.804
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 (
|
|
3
|
+
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (21/02/2024-23:41:09)»*/
|
|
4
4
|
/*-----------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
|
|
@@ -3738,6 +3738,12 @@ window.instanciate=function(className=null){
|
|
|
3738
3738
|
|
|
3739
3739
|
if(!className) return newObj;
|
|
3740
3740
|
|
|
3741
|
+
// DBG
|
|
3742
|
+
if(!className.startsWith)
|
|
3743
|
+
lognow(">>>>>>>>>>>>>>>>className:",className);
|
|
3744
|
+
|
|
3745
|
+
|
|
3746
|
+
|
|
3741
3747
|
if(className.startsWith("HTML")){
|
|
3742
3748
|
if(typeof(document)!=="undefined"){
|
|
3743
3749
|
let elementName=className.replace("HTML","").replace("Element","").toLowerCase();
|
|
@@ -4086,6 +4092,122 @@ window.areEquivalentFlatMaps=function(o1,o2,UUID_ATTR_NAME=DEFAULT_UUID_ATTR_NAM
|
|
|
4086
4092
|
return areEquivalent;
|
|
4087
4093
|
}
|
|
4088
4094
|
|
|
4095
|
+
|
|
4096
|
+
window.overlaps=(delimitedObj1,delimitedObj2)=>{
|
|
4097
|
+
return (delimitedObj2.start<=delimitedObj1.start && delimitedObj1.start<=delimitedObj2.end)
|
|
4098
|
+
|| (delimitedObj2.start<=delimitedObj1.end && delimitedObj1.end <=delimitedObj2.end);
|
|
4099
|
+
}
|
|
4100
|
+
|
|
4101
|
+
|
|
4102
|
+
window.findCommonChunks=(str1,str2,minimalLength=2,invertLogic=false,characterFilterFunction=null)=>{
|
|
4103
|
+
const results=[];
|
|
4104
|
+
|
|
4105
|
+
if(empty(str1)) return results;
|
|
4106
|
+
if(empty(str2)) return results;
|
|
4107
|
+
|
|
4108
|
+
|
|
4109
|
+
// 1) We build a binary correspondances matrix :
|
|
4110
|
+
|
|
4111
|
+
const correspondancesMatrix=[];
|
|
4112
|
+
|
|
4113
|
+
for(let i=0;i<str1.length;i++){
|
|
4114
|
+
|
|
4115
|
+
const currentCharAtRow=str1.charAt(i);
|
|
4116
|
+
|
|
4117
|
+
const row=[];
|
|
4118
|
+
for(let j=0;j<str2.length;j++){
|
|
4119
|
+
|
|
4120
|
+
const currentCharAtColumn=str2.charAt(j);
|
|
4121
|
+
|
|
4122
|
+
if( currentCharAtColumn==currentCharAtRow
|
|
4123
|
+
&& (!characterFilterFunction || characterFilterFunction(currentCharAtColumn)))
|
|
4124
|
+
row.push(true && !invertLogic);
|
|
4125
|
+
else
|
|
4126
|
+
row.push(false || invertLogic);
|
|
4127
|
+
|
|
4128
|
+
}
|
|
4129
|
+
correspondancesMatrix.push(row);
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
// 2) We try to walk through the diagonal of each found correspondance to create each chunk, and removing those already walked along the way :
|
|
4133
|
+
// This way we build the raw chunks dictionnary :
|
|
4134
|
+
for(let i=0;i<correspondancesMatrix.length;i++){
|
|
4135
|
+
|
|
4136
|
+
for(let j=0;j<correspondancesMatrix[i].length;j++){
|
|
4137
|
+
|
|
4138
|
+
if(!correspondancesMatrix[i][j]) continue;
|
|
4139
|
+
|
|
4140
|
+
let newChunk=null;
|
|
4141
|
+
|
|
4142
|
+
// Proximity algorithm : Here it's just a simple diagonal walking
|
|
4143
|
+
// (for blobs in a 2D image detection, instead of hunks in a string detection, it would be a recursive algorithm !)
|
|
4144
|
+
let k;
|
|
4145
|
+
for(k=0;(i+k)<correspondancesMatrix.length && (j+k)<correspondancesMatrix[i].length;k++){
|
|
4146
|
+
|
|
4147
|
+
if(!correspondancesMatrix[i+k][j+k]) break;
|
|
4148
|
+
|
|
4149
|
+
if(k==0){
|
|
4150
|
+
newChunk=str1[i+k];
|
|
4151
|
+
}else{
|
|
4152
|
+
newChunk+=str1[i+k];
|
|
4153
|
+
}
|
|
4154
|
+
correspondancesMatrix[i+k][j+k]=false;
|
|
4155
|
+
}
|
|
4156
|
+
if(newChunk && minimalLength<=newChunk.length){
|
|
4157
|
+
results.push(
|
|
4158
|
+
[
|
|
4159
|
+
{start:i+k-newChunk.length,end:i+k-1,value:newChunk,length:newChunk.length},
|
|
4160
|
+
{start:j+k-newChunk.length,end:j+k-1,value:newChunk,length:newChunk.length}
|
|
4161
|
+
]
|
|
4162
|
+
);
|
|
4163
|
+
}
|
|
4164
|
+
|
|
4165
|
+
}
|
|
4166
|
+
}
|
|
4167
|
+
|
|
4168
|
+
|
|
4169
|
+
// 3) We filter all the overlapping chunks definitions, meaning when chunks overlap, only the biggest is kept !
|
|
4170
|
+
|
|
4171
|
+
const refinedResults=[];
|
|
4172
|
+
for(let i=0;i<results.length;i++){
|
|
4173
|
+
let chunk1=results[i];
|
|
4174
|
+
|
|
4175
|
+
for(let j=0;j<results.length;j++){
|
|
4176
|
+
let chunk2=results[j];
|
|
4177
|
+
|
|
4178
|
+
if(overlaps(chunk1[0],chunk2[0])) continue;
|
|
4179
|
+
|
|
4180
|
+
let chosenChunk=chunk1;
|
|
4181
|
+
if(chunk1[0].length<chunk2[0].length) chosenChunk=chunk2;
|
|
4182
|
+
|
|
4183
|
+
refinedResults.push(chosenChunk);
|
|
4184
|
+
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
|
|
4188
|
+
// (we need to do the adding in both directions :)
|
|
4189
|
+
for(let i=0;i<results.length;i++){
|
|
4190
|
+
let chunk1=results[i];
|
|
4191
|
+
|
|
4192
|
+
for(let j=0;j<results.length;j++){
|
|
4193
|
+
let chunk2=results[j];
|
|
4194
|
+
|
|
4195
|
+
if(overlaps(chunk1[1],chunk2[1])) continue;
|
|
4196
|
+
|
|
4197
|
+
let chosenChunk=chunk1;
|
|
4198
|
+
if(chunk1[1].length<chunk2[1].length) chosenChunk=chunk2;
|
|
4199
|
+
|
|
4200
|
+
refinedResults.push(chosenChunk);
|
|
4201
|
+
|
|
4202
|
+
}
|
|
4203
|
+
}
|
|
4204
|
+
|
|
4205
|
+
|
|
4206
|
+
return refinedResults;
|
|
4207
|
+
}
|
|
4208
|
+
|
|
4209
|
+
|
|
4210
|
+
|
|
4089
4211
|
window.areEquivalentSimple=function(obj1Param,obj2Param, caseSensitive=true){
|
|
4090
4212
|
const str1=(isString(obj1Param)?obj1Param:stringifyObject(obj1Param));
|
|
4091
4213
|
const str2=(isString(obj2Param)?obj2Param:stringifyObject(obj2Param));
|
|
@@ -5167,7 +5289,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
|
|
|
5167
5289
|
|
|
5168
5290
|
|
|
5169
5291
|
|
|
5170
|
-
/*utils SERVER library associated with aotra version : «1_29072022-2359 (
|
|
5292
|
+
/*utils SERVER library associated with aotra version : «1_29072022-2359 (21/02/2024-23:41:09)»*/
|
|
5171
5293
|
/*-----------------------------------------------------------------------------*/
|
|
5172
5294
|
|
|
5173
5295
|
|
aotrautils-srv/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils-srv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.804",
|
|
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)",
|