I was investigating if there is any structure similar to Java SET, which does not allow duplicates in the collection. I need a structure like this to eliminate duplicates of a file
I made this code but it inserts duplicates.
> function reestructurar(dir,fileA){ var mySet = new Set();
> read('${dir}/training/${fileA}', contentT => {
> for (var i = 0, chunki = contentT.split('\n'), leni =chunki.length; i < leni; i++){
> mySet.add(chunki);
>
> }
> console.log(mySet);
> });
>
> }
modify it like this:
var Set = require ("collections / set");
function reestructurar(dir,fileA){
var set = new Set([]);
read('${dir}/training/${fileA}', contentT => {
for (var i = 0, chunki = contentT.split('\n'), leni =chunki.length; i < leni; i++){
set.add(chunki);
}
console.log(set);
});
}
It does not work, insert everything, I need you to insert not repeated