get () method of collections.js in nodejs does not work

1

I made this code

function reestructurar(dir,fileA){
    var seto = new Set([]);
    read('${dir}/training/${fileA}', contentT => {
    for (var i = 0, chunki = contentT.split('\r\n'), leni =chunki.length; i < leni; i++){

        if(seto.get(chunki)=="") { //error
            seto.add(chunki);
        }

    }

    console.log(seto);

    });
}

marks me error in the function get()

I'm using this lib link

    
asked by hubman 10.10.2016 в 17:02
source

1 answer

1

It's because chunki = contentT.split(...) is an array. You must use within the get (and the add)
 as chunki[i]

Although I recommend you use you have () that returns bool

if(!seto.has(chunki[i]) )
    seto.add(chunki[i]);
    
answered by 10.10.2016 / 17:23
source